PDO 语句错误 #1064
PDO statement error #1064
我正在尝试从 PDO 报价和 PDO 准备和执行,我的查询是这样的:
$sql = 'SELECT * FROM nav_top1 WHERE id_top = (SELECT top_fr FROM nav_top WHERE top_fr = :rub ORDER BY top1_order ASC';
echo $sql.'<br>';
$query = $connexion->prepare($sql);
$query->bindParam(':rub', $rub, PDO::PARAM_INT);
$query->execute();
$list = $query->fetchAll();
foreach ($list as $rs) {
$top1_fr = $rs['top1_fr'];
echo $top1_fr;
}
但我得到一个错误:
[Sat Mar 07 14:08:05 2015] [error] [client 105.156.126.211]
PHP Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 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 '' at line 1 in /home/www/Fashion/fashion.php on line 9, referer...
提前致谢
缺少大括号?
top1_order ASC)
$sql = 'SELECT * FROM nav_top1 WHERE id_top = (SELECT top_fr FROM
nav_top WHERE top_fr = :rub ORDER BY top1_order ASC';
您缺少牙套。
$sql = 'SELECT * FROM nav_top1 WHERE id_top = (SELECT top_fr FROM
nav_top WHERE top_fr = :rub ORDER BY top1_order ASC');
我正在尝试从 PDO 报价和 PDO 准备和执行,我的查询是这样的:
$sql = 'SELECT * FROM nav_top1 WHERE id_top = (SELECT top_fr FROM nav_top WHERE top_fr = :rub ORDER BY top1_order ASC';
echo $sql.'<br>';
$query = $connexion->prepare($sql);
$query->bindParam(':rub', $rub, PDO::PARAM_INT);
$query->execute();
$list = $query->fetchAll();
foreach ($list as $rs) {
$top1_fr = $rs['top1_fr'];
echo $top1_fr;
}
但我得到一个错误:
[Sat Mar 07 14:08:05 2015] [error] [client 105.156.126.211]
PHP Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 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 '' at line 1 in /home/www/Fashion/fashion.php on line 9, referer...
提前致谢
缺少大括号?
top1_order ASC)
$sql = 'SELECT * FROM nav_top1 WHERE id_top = (SELECT top_fr FROM nav_top WHERE top_fr = :rub ORDER BY top1_order ASC';
您缺少牙套。
$sql = 'SELECT * FROM nav_top1 WHERE id_top = (SELECT top_fr FROM
nav_top WHERE top_fr = :rub ORDER BY top1_order ASC');