Jump to content

I'm getting an "invalid argument" error for my While loop....


Jim R

Recommended Posts

I'm getting an invalid argument error for my While loop.  I can't figure out why. 

 

$sql="SELECT * FROM schools ORDER BY class DESC,sectional ASC,team ASC";

$results = mysql_query($sql);

while ($team = mysql_fetch_assoc($results)) {

echo $team['school'] . '<br>';

}

 

 

Here is the error:

 

Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/******/public_html/hoosierhoopsmagazine.com/resources/sectional_assignments.php on line 7

Link to comment
Share on other sites

okay i don't think you're understanding.. lets try something more simple..

 

$sql="SELECT * FROM schools ORDER BY class DESC,sectional ASC,team ASC";

$results = mysql_query($sql) or die(mysql_error());

while ($team = mysql_fetch_assoc($results)) {

echo $team['school'] . '<br>';

}

Link to comment
Share on other sites

I am understanding.  I put the exact code Adam told me to put, and that was what it produced, which is what I posted in the response above.

 

Yeah sorry for the confusion, I missed out E_USER_ERROR for the second parameter. If you didn't see the MySQL error though it's likely you have warning messages hidden.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.