mysql_fetch_row()函数显示警告

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.

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());

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
   }
}