我收到此错误:变量数与预准备语句中的参数数量不匹配 每次我运行这段代码:
$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();
有什么问题?
答案 0 :(得分:2)
尝试将所有参数放入一个bindParam
来电:
$stmt->bind_Param('sds', $username, $picture, $comment);