Create table not working

I used PHP to create a table, and it worked. I then tried to create a second table and this one failed.

ini_set('display_errors', true);

$server= "************";     /* Address of database server */ 
$user="************";           /* Database username */ 
$password="*********";          /* Database Password */
$database="**********";        /* name of database */

mysql_connect($server,$user,$password) or die ( "<H3>Server unreachable</H3>");
@mysql_select_db($database) or die( "Unable to select database");

$query="CREATE TABLE two ( id varchar(50) NOT NULL default '', userid varchar(10) NOT NULL default '', ip varchar(20) NOT NULL default '', tm datetime NOT NULL default '0000-00-00 00:00:00', status char(3) NOT NULL default 'ON' ) TYPE=MyISAM;";

This is identical to what I used to create the first table, but the table does not get created (verified using PHPmyadmin). I suspect the code is not good code, but i am using it to learn, so don’t worry about my feelings if it is a mess.

Have both tables that you’re trying to create got different names? I tried the create table query locally and the table created fine.

WOW! I just found the error. There is a stray ) in the code. Once I removed that ) I was able to create the table.

I also realized that the code I posted above is for table one, which worked. :blush:

My bad.

Yes, both tables have different names. Is it necessary to have completely unique table names. The actual names I used were group_one and group_two. Would this make a difference?


and you’re saying that other than the table name, the tables are identical? or are you saying that the php you used is identical, but the tables have different columns?

may i ask why you’re even using php to create tables? it’s not as though you were planning on creating tables over and over again (i hope)