3

这是我的编码:

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`

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

4

1 回答 1

4

如果您想在 MySQL 中转义保留字,order使用反引号而不是引号:

INSERT INTO `Order` ...

引号是字符串分隔符。

于 2013-07-27T21:34:31.047 回答