以下错误会触发mysql错误,这是由于查询未将参数绑定到语句。我不明白为什么会这样。
这是else子句返回的错误:
ERROR -> 1064 : 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 '? ORDER BY dateCreated DESC' at line 4`
以下是相关代码:
$userId = 1;
if ($stmt = $link->query("
SELECT o.id, dateCreated, firstValue
FROM user_orders o
LEFT JOIN order_delivery d ON o.id = d.id
WHERE o.userId = ?
ORDER BY dateCreated DESC
"))
{
$stmt->bind_param("i", $userId);
$stmt->execute();
$stmt->close();
}
else
{
$pageContent = '
<p>ERROR -> '.$link->errno.' : '.$link->error.'</p>
';
}
有人可能指出我的错误,以及为什么会出现这个mysql错误。
感谢您抽出宝贵时间阅读本文!