我的 SQL 查询是SELECT * FROM chat WHERE to = '$user_id' AND client_id = '001' LIMIT 4
由于某种原因,该查询给了我以下错误:
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 'to = '1' AND client_id = '001' LIMIT 4' at line 1
我使用了不同的行并且查询运行得非常好——错误是因为“to”这个词吗?或者这背后还有别的什么?
仅供参考,这里是 PHP:
$user_id = $_SESSION['user_id'];
$client_id = '001';
if (!$query = sql("SELECT * FROM arrowchat WHERE to = '$user_id' AND client_id = '$client_id' LIMIT 4")) {
echo mysql_error();
} else {
echo 'success';
}