Jump to content


Photo

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


  • Please log in to reply
2 replies to this topic

#1 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 01 April 2006 - 10:18 AM

I have no idea why it won't work, and it's driving me insane.

This code works:
$query=mysql_query("SELECT * FROM $tablename ORDER BY player asc");
while($row = mysql_fetch_array($query)) {
echo("

This code does not work:
$query=mysql_query("SELECT * FROM $tablename WHERE show ='yes' ORDER BY player asc");
while($row = mysql_fetch_array($query)) {
echo("

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

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 April 2006 - 11:11 AM

To find out why your sql query is failing chnage your query line to this:
$query=mysql_query("SELECT * FROM $tablename WHERE show ='yes' ORDER BY player asc") or die("Error with query: " . mysql_error());
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.

#3 yarub

yarub
  • Members
  • PipPipPip
  • Advanced Member
  • 72 posts
  • LocationSioux City, IA

Posted 02 April 2006 - 06:28 AM

You sir, are a genius. =D I changed show to display and it works now. Thank you very much.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users