sark9012
sark9012

Reputation: 5747

mysql fetch error

    <? 
    $res = $database->userLatestStatus($u);
    while($row=mysql_fetch_assoc($res)){
       $status=$row['status'];
       echo "$status";
    }
    ?>

This is the code on my page, which is throwing up the following error: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource....

The database function:

   function userLatestStatus($u)
   {
       $q = "SELECT status FROM ".TBL_STATUS." WHERE userid = '$u' DESC LIMIT 1";
       return mysql_query($q, $this->connection);
   }

Any ideas what the problem is?

Upvotes: 0

Views: 160

Answers (2)

Abhijeet Pathak
Abhijeet Pathak

Reputation: 1948

Use a query like ORDER BY UPDATETIME DESC or remove DESC

Upvotes: 1

Soufiane Hassou
Soufiane Hassou

Reputation: 17750

DESC should be used with ORDER BY.

Upvotes: 0

Related Questions