-
MySQL: CREATE TABLE
I'm having a problem with this:
PHP Code:
$db = mysql_connect("localhost", "user", "password");
mysql_select_db("database",$db);
$sql = "INSERT INTO cats (name,tablename) VALUES ('$name','$tablename')";
$sql2 = "CREATE TABLE $tablename (id tinyint(4) DEFAULT '0' NOT NULL AUTO_INCREMENT, name varchar(20), desc text, code text, PRIMARY KEY (id), UNIQUE id (id))";
$result = mysql_query($sql);
$result2 = mysql_query($sql2);
What's wrong with this code?
The INSERT INTO works, but the CREATE TABLE never creates the table?? :confused:
-
desc is a reserved word, for the ORDER BY SQL statement. That may be causing your problem.
I would make your result2 the following to see what MySQL Error you get:
PHP Code:
result2 = mysql_query2($sql2) or die(mysql_error());
-Matt
-
Quote:
Originally posted by cpradio
desc is a reserved word, for the ORDER BY SQL statement. That may be causing your problem.
I would make your result2 the following to see what MySQL Error you get:
PHP Code:
result2 = mysql_query2($sql2) or die(mysql_error());
-Matt
and that it was. Thanks alot, Matt. :)
-
yep i had that same problem the other day