Current location: Hot Scripts Forums » Programming Languages » PHP » creating a database


creating a database

Reply
  #1 (permalink)  
Old 11-19-04, 07:18 PM
ultra-net ultra-net is offline
Newbie Coder
 
Join Date: May 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
creating a database

i got this coding for creating some part of a database

<?
$user="username";
$password="password";
$database="database";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="CREATE TABLE contacts (id int(6) NOT NULL auto_increment,first varchar(15) NOT NULL,last varchar(15) NOT NULL,phone varchar(20) NOT NULL,mobile varchar(20) NOT NULL,fax varchar(20) NOT NULL,email varchar(30) NOT NULL,web varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";
mysql_query($query);
mysql_close();
?>

thast all very well, but i stil dont know how to actully make one and put things wherever they go. could someone maybe give me an example of one set-up or some help for this. thanks, and please someone repaly, none of my essages have been replied to yet on other boards
Reply With Quote
  #2 (permalink)  
Old 11-19-04, 07:23 PM
1jetsam 1jetsam is offline
Wannabe Coder
 
Join Date: Apr 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Code:
<?php
define('SQL_HOST','localhost');
define('SQL_USER','****');
define('SQL_PASS','****');
define('SQL_DB','****');

$conn = mysql_connect(SQL_HOST,SQL_USER,SQL_PASS)
  or die('A connection error occurred (1): ' . mysql_error());

mysql_select_db(SQL_DB,$conn)
  or die('A connection error occurred (2): ' . mysql_error());

$bank = "CREATE TABLE bank (
  bank_id int(11) NOT NULL auto_increment,
  bank_amount int(11) NOT NULL,
  bank_username text NOT NULL,
  bank_date datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY (bank_id)
)";
$results8 = mysql_query($bank) or die (mysql_error());
echo "Successfully created!";
?>
There is some copy and paste for you, just slightly edited.
__________________
Quate CMS 0.3.3 Released - A simple, fast Content Management System.
Reply With Quote
  #3 (permalink)  
Old 11-20-04, 12:20 AM
subnet_rx subnet_rx is offline
Newbie Coder
 
Join Date: Nov 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
I'd look at some tutorials and there are many on the web about PHP/MySQL
Reply With Quote
  #4 (permalink)  
Old 11-20-04, 05:09 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
custom coding: jas[at]programmer[dot]net
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Form to update a MySQL database? Scoobler PHP 9 09-04-08 01:41 AM
creating a database driven community website ak_russ Job Offers & Assistance 5 08-14-04 05:54 PM
Error while creating database (Errornumber 2002: "Can't connect to local MySQL server lylesback2 PHP 5 04-11-04 01:37 PM
error when creating database tables with php script spiroth10 PHP 4 01-06-04 03:59 PM


All times are GMT -5. The time now is 05:14 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.