警告:PDOStatement :: execute():SQLSTATE [HY093]:参数号无效

时间:2014-04-07 18:06:30

标签: php pdo

我使用pdo选择陈述时出错,我不明白为什么会这样做。

你觉得这里有什么不对吗?

我遇到此错误:

  

警告:PDOStatement :: execute():SQLSTATE [HY093]:参数号无效:参数未在$ readGallery-> execute();

中定义
$delId = $_GET['delid'];
$thumb = $_GET['thumb'];
$folder = '../uploads/';
$readGallery = $pdo->prepare("SELECT * FROM gallery WHERE news_id = ?");
$readGallery->bindParam(':news_id', $delId);
$readGallery->execute();
$numGallery =   $readGallery->rowCount();

1 个答案:

答案 0 :(得分:2)

更改

$readGallery = $pdo->prepare("SELECT * FROM gallery WHERE news_id = ?");

$readGallery = $pdo->prepare("SELECT * FROM gallery WHERE news_id = :news_id");