准备语句帮助,变量数与预准备语句中的参数数量不匹配

时间:2011-01-08 08:37:15

标签: php prepared-statement

我收到此错误:变量数与预准备语句中的参数数量不匹配 每次我运行这段代码:

$dbh = new mysqli("localhost", "***", "***", "pics");
    $stmt = $dbh->prepare("INSERT INTO comments (username, picture, comment) VALUES (?, ?, ?)");
   $stmt->bind_Param('s', $username);
   $stmt->bind_Param('d', $picture);
   $stmt->bind_Param('s', $comment);

   $username=$_SESSION['username'];
   $picture=$_GET['id'];
   $comment=$_POST['comment'];
   $stmt->execute();

有什么问题?

1 个答案:

答案 0 :(得分:2)

尝试将所有参数放入一个bindParam来电:

$stmt->bind_Param('sds', $username, $picture, $comment);