0

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 !

1
  • 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. Commented Sep 12, 2010 at 16:42

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.