2

这是查询

 $query_order = "select * from orders where key = '$pay_key'";

显示错误

SELECT 
    * 
FROM `orders` 
where `key` = 'C90320'

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 'key = 'C90320'' at line 1*
4

3 回答 3

1

key是保留字。将您的查询更改为:

$query_order = "select * from orders where `key` = '$pay_key'";

另外,我建议转义$pay_key' 值。像这样说:

$pay_key = mysqli_real_escape_string($pay_key);
于 2013-03-02T06:08:59.563 回答
0
 $query_order = "select * from orders 
                 where `key` = '".mysqli_real_escape_string($pay_key)."'";
于 2013-03-02T06:11:05.463 回答
0

尝试这个

首先你需要使用字符串比较它所以代码应该是这样的

 $query_order = "select * from orders where `key` = '".$pay_key."'";
于 2013-03-02T06:19:15.610 回答