我编写了一些SQL并运行它来查找几乎所有表中的错误。这是我为表格所得到的错误:
Error creating table 'Region': You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version
for the right syntax to use near
'desc varchar(25) NOT NULL, PRIMARY KEY(regID))' at line 1
我的代码:
mysql_select_db($dbName, $dbConnection);
$sql = "CREATE TABLE ".$dbTableRegion." (regID int(4) auto_increment NOT NULL, desc varchar(25) NOT NULL, PRIMARY KEY(regID))";
if(mysql_query($sql, $dbConnection))
{
echo("Table '".$dbTableRegion."' created<br />");
}
else
{
echo("Error creating table '".$dbTableRegion."': ".mysql_error()."<br />");
}
答案 0 :(得分:0)
请在此行重命名desc
:
desc varchar(25) NOT NULL
其他东西,因为它是MySQL中的reserverd word:
some_stuff varchar(25) NOT NULL