“您的SQL语法中有错误;”接近table_name

时间:2021-11-01 02:18:01

This is my Coding :

这是我的编码:

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());

After i run that coding, i got this 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`

I wonder where my mistakes is..

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

1 个解决方案

#1


4  

If you want to escape reserved words in MySQL like order then do it with backticks and not with quotes:

如果你想要在MySQL中转义像order这样的保留词,那就用回勾而不是引号:

INSERT INTO `Order` ...

Quotes are string delimiters.

引号字符串分隔符。

#1


4  

If you want to escape reserved words in MySQL like order then do it with backticks and not with quotes:

如果你想要在MySQL中转义像order这样的保留词,那就用回勾而不是引号:

INSERT INTO `Order` ...

Quotes are string delimiters.

引号字符串分隔符。