Jump to content

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


yarub

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? >_<;
Link to comment
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.
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.