csu_bill — 2011-07-09T17:23:41-04:00 — #1
I used PHP to create a table, and it worked. I then tried to create a second table and this one failed.
$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.
spacephoenix — 2011-07-09T17:33:05-04:00 — #2
Have both tables that you're trying to create got different names? I tried the create table query locally and the table created fine.
csu_bill — 2011-07-09T20:43:32-04:00 — #3
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.
csu_bill — 2011-07-09T20:22:07-04:00 — #4
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?
r937 — 2011-07-09T20:34:26-04:00 — #5
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)