我将此代码用于另一个表,它正常工作,然后当我将其用于同一数据库的另一个表时,它向我显示此错误
PHP致命错误:未捕获的错误:在布尔值中调用成员函数execute()
我找到了尝试的解决方案,但该解决方案无法帮助我
$heroes = array();
$sql = "SELECT id,class_name,image,url FROM time_table;";
mysqli_set_charset($conn,'utf8');
$stmt = $conn->prepare($sql);
$stmt->execute();
$stmt->bind_result($id,$class_name,$image,$url);
while($stmt->fetch()){
$temp = [
'id'=>$id,
'class_name'=>$class_name,
'image'=>$image,
'url'=>$url
];
array_push($heroes, $temp);
}
echo json_encode($heroes);