嗨,我正在检查 fetch 数组是否会给我 0 行数据,所以我使用 num_row() 但我总是给我一个错误
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\PostImages\displayImages.php on line 8
这是我使用的代码
<?php
$con = mysqli_connect('127.0.0.1', 'root', '', 'test');
$id = mysqli_real_escape_string($con,$_REQUEST['id']);
$query = "SELECT image_posts FROM ratepicture WHERE id = ".$id."";
$image = mysqli_query($con, $query);
if(mysqli_num_rows($image) == 0)
{
$queryError = "SELECT image FROM error_pictures WHERE id = 1";
$error = mysqli_query($con, $queryError);
$error = mysqli_fetch_assoc($error);
$error = $error['image'];
echo $error;
}else
{
$image = mysqli_fetch_assoc($image);
$image = $image['image_posts'];
echo $image;
}
?>