我有这个问题:
qry=INSERT INTO assessments (Speaking_and_listening, Reading, Writing, Number, Measure, Geometry, Statistics, Science, ICT, Health_and_well_being, Relationships, Living_in_the_wider_world ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
我停止了两个变量和一个循环来进行绑定:
foreach ($subjectListArray as $key=>$subject){
$sss .='s';
if (!isset($_POST[str_replace(" ","_",$subject)])){
$fieldNameValues.='fred';
}else{
$fieldNameValues.=$_POST[str_replace(" ","_",$subject)];
}
if ($key!=(count($subjectListArray)-1)){
$sss.=' ,';
$fieldNameValues.=', ';
}
}
当我打印出两个数组$sss
和$fieldNameValues
时,我得到了这个:
s ,s ,s ,s ,s ,s ,s ,s ,s ,s ,s ,s
p2iic, fred, fred, fred, fred, fred, fred, fred, fred, fred, fred, fred
哪个看起来对我来说。
然而,当准备和绑定时:
$record= $conn->prepare($qry);
$record-> bind_param($sss, $fieldNameValues);
我收到错误告诉我
Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables
据我所知 - $ ary中有12个,$ sss中有12个,$ fieldNamesValues中有12个
请问有什么不对?