Jump to content

Archived

This topic is now archived and is closed to further replies.

yarub

WHERE field ='value' is't working...

Recommended Posts

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? >_<;

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
You sir, are a genius. =D I changed show to display and it works now. Thank you very much.

Share this post


Link to post
Share on other sites

×

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.