我想要设置req_status = "UNDONE"
。我是否正确地在sql中声明了?我是新人。它表示警告:mysql_fetch_array()
期望参数1为资源,布尔值在
$res = mysql_query("SELECT * FROM request WHERE req_user = '$un',req_status = 'UNDONE' ORDER BY req_status DESC,req_important ASC,req_dateReceive DESC ");
答案 0 :(得分:1)
您收到此错误是因为您的查询无法执行,因为其中存在错误。
您必须使用SELECT WHERE
或AND
在OR
中区分条件。
$res = mysql_query("SELECT * FROM request WHERE req_user = '$un',req_status = 'UNDONE' ORDER BY req_status DESC,req_important ASC,req_dateReceive DESC ");
^
更改为
$res = mysql_query("SELECT * FROM request WHERE req_user = '$un' AND req_status = 'UNDONE' ORDER BY req_status DESC,req_important ASC,req_dateReceive DESC ");
^
答案 1 :(得分:0)
$res = mysql_query("
SELECT *
FROM request
WHERE req_user = '$un'
AND req_status = 'UNDONE'
ORDER BY req_status DESC,
req_important ASC,
req_dateReceive DESC
");
逗号绝对不能使用语法。尝试使用AND。
expects parameter 1 to be resource, boolean given in
意味着PHP期望返回某种形式的资源(如数组),但在查询失败时它返回false
。
另外,请不要使用mysql,因为它已被弃用,并且已经存在更安全的方法来防止 SQL注入(了解有关PDO或mysqli的更多信息)
答案 2 :(得分:0)
用
替换上面的内容 $res = mysql_query("SELECT * FROM request WHERE req_user = '$un' AND req_status = 'UNDONE' ORDER BY req_status DESC,req_important ASC,req_dateReceive DESC ");