我一直在为我们网站的基础论坛工作。我使用PDO查询时出现了一些问题:
number of bound variables does not match number of tokens
这是由这个fllowing代码引起的:
$stmt1 = $conn->prepare("UPDATE topics SET replies=:replies, lastposter=:poster, lastpostdate=:date WHERE id = :id");
$stmt1->bindParam(':id', $id);
$stmt1->bindParam(':replies', $replies);
$stmt1->bindParam(':poster', $poster);
$stmt1->bindParam(':date', $date);
$stmt1->execute();
$id
,$replies
和$date
是整数,$poster
是一个字符串。我上面有一个类似的查询,工作得很好,如下:
$stmt1 = $conn->prepare("UPDATE main SET topics = :topics, lastposter = :poster, lastpostdate = :date WHERE id = :id");