-3

Hi i get mysql_fetch_row(): supplied argument is not a valid MySQL result here is my code

$query="select DISTINCT categories_memories.memory_id from categories_memories INNER JOIN categories ON categories.id=categories_memories.category_id";

$res=mysql_query($query);

while($row=mysql_fetch_row($res))
{

}

please guide me

Thanks for advance.

Chithri Ajay
  • 907
  • 3
  • 16
  • 37
  • Duplicate of http://stackoverflow.com/questions/169520/warning-when-using-mysql-fetch-assoc-in-php – vstm Apr 05 '12 at 08:33

2 Answers2

0

Your query failed so mysql_query() returned false which is not a valid MySQL result.

You need to have a look at the SQL error to fix it, here's a simple (but horrible) way to get the error in case one happens:

$res = mysql_query($query) or die(mysql_error());
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
0

SQL query supplies empty result set so mysql_fetch_row generate warning to avoid try below code

if($res){
   while($row=mysql_fetch_row($res))
   {
      do something
   }
}
Hardeep Pandya
  • 897
  • 1
  • 8
  • 27