$sql_project_material = "SELECT * FROM project_material";
if($result_project_material = $connect->query($sql_project_material))
{
$rows_project_material = $result_project_material->fetch_array();
$total_project_material = $result_project_material->num_rows;
$num_project_material = 0;
}
答案 0 :(得分:0)
您的$result_project_material
可能为空或您的查询失败。
尝试一步一步地找出错误的位置,在调用fetch_array()
之前检查结果是否为空。
$connect = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($connect->connect_errno) {
printf("Connect failed: %s\n", $connect->connect_error());
exit();
}
$result_project_material = $connect->query($sql_project_material);
if($total_project_material = $result_project_material->num_rows > 0) {
while($result_array = $result_project_material->fetch_array()) {
$rows_project_material[] = result_array;
}
}else{
$rows_project_material = array();
echo "Empty Result";
}