I am getting this message and I have checked my code and it seems to be all OK but I ther another reason that this message is showing up, that I maigt not know. PLESE HELP....

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in file.php on line 15

This means that the query that you are fetching the array from is wrong.. can you please post the query from which you are using the mysql_fetch_array() function?? That will help us solve your problem easier.

As mentioned in the Faq, the common problem that I use to have was that no results were returned. So try adding the following if statement around the while loop:

$r = mysql_query('SELECT * FROM `table`') or die(mysql_error());
if (mysql_num_rows($r)>0) {
while ($row=mysql_fetch_array($r)) {
    echo $row[0].'<br>';
    }
}

Also make sure you have the or die(mysql_error()); after the mysql query. That usually does the trick even though it has been said that there are other ways to receive the same error. Below is an alternative while loop which I have been told you shouldn't need the if function for.

$r = mysql_query('SELECT * FROM `table`') or die(mysql_error());
while ($row=mysql_fetch_assoc($r)) {
    echo $row['column'].'<br>';
    }

I might see if I can find a way to add to the tutorials and code snippets sections to help people with these common errors.

I solved the isue by adding `` to the variable

SELECT * FROM `$table`
some how it gets mest up , proabably because I have capital letters and spaces in my table names...

This article has been dead for over six months. Start a new discussion instead.