Getting the following error : Number of variables doesn't match number of parameters in prepared statement
Getting the following error : Number of variables doesn't match number of parameters in prepared statement
我收到这个错误:
变量数与准备语句中的参数数不匹配
我想我写的语句是正确的,参数的数量也是一样的。请指正。
function Hello($questionId){
global $mysqli,$db_table_prefix;
$stmt = $mysqli->prepare("
SELECT
id,
answerby ,
answer,
questionId
FROM ".$db_table_prefix."answers
WHERE `questionid` = 1
");
$stmt->bind_param("s",$questionId);
$stmt->execute();
$stmt->bind_result($id, $answerby, $answer,$questionId);
while ($stmt->fetch()){
$row = array('id' => $id, 'answerby' => $answerby, 'answer' => $answer, 'questionId' => $questionId);
}
$stmt->close();
return $row;
}
我编辑了代码使其可以运行。
函数你好($questionId){
global $mysqli,$db_table_prefix;
$stmt = $mysqli->prepare("
SELECT
id,
answerby ,
answer,
questionId
FROM ".$db_table_prefix."answers
WHERE `questionid` = ?
");
$stmt->bind_param("i",$questionId);
$stmt->execute();
$stmt->bind_result($id, $answerby, $answer,$questionId);
while ($stmt->fetch()){
$row = array('id' => $id, 'answerby' => $answerby, 'answer' => $answer, 'questionId' => $questionId);
}
$stmt->close();
return $row;
}
我收到这个错误: 变量数与准备语句中的参数数不匹配 我想我写的语句是正确的,参数的数量也是一样的。请指正。
function Hello($questionId){
global $mysqli,$db_table_prefix;
$stmt = $mysqli->prepare("
SELECT
id,
answerby ,
answer,
questionId
FROM ".$db_table_prefix."answers
WHERE `questionid` = 1
");
$stmt->bind_param("s",$questionId);
$stmt->execute();
$stmt->bind_result($id, $answerby, $answer,$questionId);
while ($stmt->fetch()){
$row = array('id' => $id, 'answerby' => $answerby, 'answer' => $answer, 'questionId' => $questionId);
}
$stmt->close();
return $row;
}
我编辑了代码使其可以运行。
函数你好($questionId){
global $mysqli,$db_table_prefix;
$stmt = $mysqli->prepare("
SELECT
id,
answerby ,
answer,
questionId
FROM ".$db_table_prefix."answers
WHERE `questionid` = ?
");
$stmt->bind_param("i",$questionId);
$stmt->execute();
$stmt->bind_result($id, $answerby, $answer,$questionId);
while ($stmt->fetch()){
$row = array('id' => $id, 'answerby' => $answerby, 'answer' => $answer, 'questionId' => $questionId);
}
$stmt->close();
return $row;
}