它显示如下错误:
Warning: mysqli_query(): Couldn't fetch mysqli in C:\xampp\htdocs\kidstore\admin\init\dataconfig.php on line 94
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\kidstore\admin\init\dataconfig.php on line 95
Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\kidstore\admin\add-category.php on line 142
这是我的代码:
// fetch all data from database for all category in display
function select_categories($connectionStatus){
$query = "SELECT * FROM `categories` WHERE parent = 0";
$result = mysqli_query($connectionStatus, $query);
if(mysqli_num_rows($result) > 0){
mysqli_close($connectionStatus);
return $result;
}
return false;
}
答案 0 :(得分:0)
嗨问题出在这一行
$result = mysqli_query($connectionStatus, $query);
添加mysqli_error()
$result = mysqli_query($connectionStatus, $query) or die(mysqli_error($connectionStatus));
您的mysqli_connect()
也在哪里。
您的query
没有执行这就是您获得errors
如果一切正常,那么一旦在php中运行你的$query
并检查它是否给出了结果。但在此之前请检查connection
。