View Single Post
  #1 (permalink)  
Old 04-18-06, 07:48 PM
theecontutor theecontutor is offline
New Member
 
Join Date: Apr 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
creating table in mysql using a script.

Hi i am trying to create a table using a script. I am new to mysql so i'm not familar with all of the syntax.
Can someone help me with my code. I want to create a table name with space using a script. I can do this using phpmyadmin but i have a lot of tables to create and i would like to use a script.
here's a copy of my code:
PHP Code:

<?

include("dbinfo.php");
mysql_connect(mysql,$username,$password);
@
mysql_select_db($database) or die( "Unable to select database");
$tablename "ECON 1 (Scott) HW";
$query"CREATE TABLE $tablename (time datetime NOT NULL default '0000-00-00 00:00:00', first_name varchar(30) NOT NULL, last_name varchar(30) NOT NULL, email varchar(50) NOT NULL, PRIMARY KEY (time)
)"
;

mysql_query($query);
mysql_close(); 
echo 
"Database created";
?>
any suggestions?

Last edited by Christian; 04-19-06 at 01:31 PM. Reason: Please use [PHP][/PHP] when posting PHP code!
Reply With Quote