我是PHP和MySQL的新手,我正在尝试执行以下代码以使用Roll_no($sub
)项来更新列(作为变量$Roll_no
传递)存储在数组($marks
)中。
$j=1;
$query="SELECT * FROM stu_info WHERE Class='$cls'";
$row = mysqli_query($conn, $query);
while($result=mysqli_fetch_array($row,MYSQLI_ASSOC))
{
$marks[$j]=$_POST['marks'][$j];
$Roll_no=$result['Roll_No'];
$statement=mysqli_prepare($conn, "UPDATE result SET $sub=? WHERE Roll_no=?");
$statement->bind_param("ii", $marks[$j], $Roll_no);
if(!$statement) die(mysqli_error);
$execution=mysqli_query($conn, $query) or die(mysqli_error);
$j=$j+1;
}
执行后,mysqli_prepare()语句中出现以下错误-
Uncaught Error: Call to a member function bind_param() on boolean