-1

This is my Query and i am getting error mysql_fetch_assoc() expects parameter 1 to be resource, boolean given on line 91

$result = mysql_query(
            "SELECT (LEFT(post, 3) AS message), user_id, fname, message, topic,              
                    date, pid 
               FROM forum_post 
               order by times desc 
               LIMIT 10");

while (($row = mysql_fetch_assoc($result))>0) {
    $user_id=$row['user_id'];
$fname=$row['fname'];
$message=$row['message'];
$topic=$row['topic'];
$date=$row['date'];
$pid=$row['pid'];
}
Pete B.
  • 3,096
  • 6
  • 23
  • 38
Ila Buddy
  • 1
  • 2
  • Please note that the `mysql_xxx()` functions are deprecated. It is recommended to stop using them and switch to one of the more modern alternatives such as the PDO library. – Spudley Aug 18 '13 at 10:08

1 Answers1

1

http://php.net/manual/en/function.mysql-query.php

For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error.

My guess is, your mysql_query() returned False (a boolean), so you should double-check your query.

Edit: didn't notice it's a duplicate, go see the linked question for more details.

Dunno
  • 3,522
  • 3
  • 26
  • 41