yarub Posted April 1, 2006 Share Posted April 1, 2006 I have no idea why it won't work, and it's driving me insane.This code works:[code]$query=mysql_query("SELECT * FROM $tablename ORDER BY player asc");while($row = mysql_fetch_array($query)) {echo("[/code]This code does not work:[code]$query=mysql_query("SELECT * FROM $tablename WHERE show ='yes' ORDER BY player asc");while($row = mysql_fetch_array($query)) {echo("[/code]The difference being the WHERE show ='yes' part. I have several scripts using the exact same command and they work perfectly. For some weird reason, I'm getting the following error when I insert that WHERE statement...[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource ../index.php on line 45[/quote]Can anyone help me? >_<; Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted April 1, 2006 Share Posted April 1, 2006 To find out why your sql query is failing chnage your query line to this:[code]$query=mysql_query("SELECT * FROM $tablename WHERE show ='yes' ORDER BY player asc") or die("Error with query: " . mysql_error());[/code]When you run your query again MySQL will report back why your query is failing.However I think MySQL maybe getting confused as show is a predefined word in mySQL so if you surround show in backticks like so: `show` it may help. Quote Link to comment Share on other sites More sharing options...
yarub Posted April 2, 2006 Author Share Posted April 2, 2006 You sir, are a genius. =D I changed show to display and it works now. Thank you very much. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.