0

I want set req_status = "UNDONE" . Did I declare in sql correctly? I'm new . It says Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in

 $res = mysql_query("SELECT * FROM request WHERE req_user = '$un',req_status = 'UNDONE' ORDER BY req_status DESC,req_important ASC,req_dateReceive DESC ");
Ram Sharma
  • 8,536
  • 7
  • 42
  • 55
lightyagami
  • 37
  • 1
  • 8

3 Answers3

1

You got this error because your query failed to execute as there is an error in it.

You have to separate conditions in SELECT WHERE using AND or 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 ");
                                                                ^

Change to

$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 ");
                                                                  ^
Jenz
  • 8,172
  • 7
  • 41
  • 75
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 
                                            ");

Syntax is definitely not correct with the comma. Try to use AND.

expects parameter 1 to be resource, boolean given in

Means that PHP expected some form of resource in return (like an array), but it got back false as the query failed.

Also, please do not use mysql as it is deprecated and safer methods already exists to prevent SQL injection (learn more about PDO or mysqli)

Alex Szabo
  • 3,259
  • 2
  • 21
  • 30
0

Replace the above with

  $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 ");
WordpressCoder
  • 307
  • 1
  • 7