-3

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

0

2 Answers 2

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());
Sign up to request clarification or add additional context in comments.

Comments

-1

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

1 Comment

Empty result set doesn't cause an error like this. Only an error does.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.