I'm trying to make a simple mysql_fetch_array but for some reasons I get the error

"Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\wamp\www\get.php on line 5"

$sql = mysql_query("SELECT * FROM mxc WHERE exp_year > 2009 AND status=0 GROUP BY c_number");

 while($row = mysql_fetch_array($sql))
{
....

Any idea what's wrong with my code ? thanks in advance for any help !

link|improve this question

77% accept rate
From my experience, such errors occur when an invalid query is given. Queries can be invalid for silly reasons such as typo in name of column. You could do a double check on that. – Shamim Hafiz Sep 12 '10 at 16:42
feedback

1 Answer

up vote 4 down vote accepted

Chances are you have a mysql error. Change your query line to this:

$sql = mysql_query("SELECT * FROM mxc WHERE exp_year > 2009 AND status=0 GROUP BY c_number") or trigger_error(mysql_error());

And see what output you get.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.