我不知道为什么但我的语法错误,我的代码对我来说完全没问题,
$page = $_POST['page'];
$amount = $_POST['amount'];
$Realpage = intval($page);
$Realamount = intval($amount);
$query = $con->prepare(
"SELECT
*
FROM
store
AS
s
INNER JOIN
product_pictures AS pp
ON
s.product_id = pp.id
INNER JOIN
product_name AS pn
ON
s.product_id = pn.id
WHERE
(s.product_price BETWEEN :firstPrice AND :secondPrice) AND
product_name LIKE :input LIMIT :page , :amount ");
$query->execute(array(':input' => "%" . $input . "%" , ":firstPrice" => intval($firstPrice), ":secondPrice" => intval($secondPrice) , ':page' => $Realpage * $Realamount, ':amount' => $Realamount));
错误:
致命错误:带有消息'SQLSTATE [42000]的未捕获异常'PDOException':语法错误或访问冲突:1064 SQL语法中有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行'''附近使用正确的语法'','20''
答案 0 :(得分:1)
SQL中的LIMIT和PAGE不能成为语句准备的一部分。