mysql-在table_name附近出现“您的SQL语法有错误;”错误

这是我的编码:

session_start();
include 'Connect.php';
$userid=$_SESSION['userid'];
$tanggal=date('Y-m-d h:i:s');
$status='Pending';  

echo $userid;
echo $status;
echo $tanggal;

mysql_query("INSERT INTO 'Order' (IdPelanggan,Tanggal,StatusOrder) VALUES ('$userid', '$tanggal', '$status')") or die (mysql_error());

运行该编码后,出现此错误:

 `9Pending2013-07-27 11:25:54You have an error in your SQL syntax; check the manual that     corresponds to your MySQL server version for the right syntax to use near 'Order (IdPelanggan,Tanggal,StatusOrder) VALUES (9, 2013-07-27 11:25:54, Pending)' at line 1`

我不知道我的错误在哪里.

解决方法:

如果要像命令一样转义reserved words in MySQL,请使用反引号而不是引号:

INSERT INTO `Order` ...

引号是字符串定界符.

上一篇:连接N-1和N-N的mySQL嵌套


下一篇:python分配“ mylist [:] = somelist”和“ mylist = somelist”有何不同?