我正在使用以下查询来显示一些信息:
$result = mysqli_query ($con,"SELECT * FROM files,members,member_group WHERE files.member_id = members.member_id AND members.member_id = member_group.member_id AND group_id='$id' ORDER BY count DESC ");
我的问题是当我遗漏ORDER BY count DESC
时它工作正常但是当它在那里时我收到以下错误:
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /proj/co600/project/repo/public_html/select_field3.php on line 227
Count是我的数据库中的一列,用于记录下载发布的次数。
答案 0 :(得分:4)
count
是一个聚合函数,所以你需要用反引号括起来。
要清楚地了解您的错误..您需要更改代码...
$result = mysqli_query ($con,"SELECT * FROM files,members,member_group WHERE files.member_id = members.member_id AND members.member_id = member_group.member_id AND group_id='$id' ORDER BY count DESC ");
if(!$result)
{
die(mysqli_error($con));
}
答案 1 :(得分:-1)
您在表中使用MySQL保留关键字作为列名。
使用以下查询:
$result = mysqli_query ($con,"SELECT * FROM files,members,member_group WHERE files.member_id = members.member_id AND members.member_id = member_group.member_id AND group_id='$id' ORDER BY `count` DESC ");