UBB.Dev
Posted By: jfeccker Unknown column 'yes' in 'where clause': 1054 - 09/27/2001 6:44 PM
You're gonna love this one. This is in the PHP version 5.4.3.

I'm viewing the list of private messages in my inbox (viewmessages.php). I click on one of the messages to read it, and get this error:

==========
SQL ERROR: Unable to do_query: SELECT M_Subject,M_Sender,M_Message,M_Sent,M_Status FROM w3t_Messages WHERE
M_Username = 'eccker_john' AND M_Number = yes
Unknown column 'yes' in 'where clause': 1054
=============

I tried a bunch of things - putting quotes around the $message variable in the query, grouping the parts of the query with ( ), etc., but I keep getting the same error (even if 'yes' is in quotes).

Then part of my thick skull parted and I realized that 'yes' isn't a valid value for $message - it should be the number of the message the person clicked on. When I look at the link on the previous page, it definately has "&message=11' in there correctly. But the value that keeps showing up in the next script is 'yes' instead of '11'. I rearranged the order of the arguments in that link to see if that helped (this helped in the past with another script), but no luck.

All this was using Netscape (4.7). I then viewed the page using IE5, and it worked perfectly - and all I did was copy the URL of the page that gave me the error from Netscape into IE, I didn't go through the whole message board system to arrive at that page. (even in Netscape, the URL in the address bar reads correctly, but there's some disconnect between what that says and what the server received)

I even added a line at the very top of viewmessage.php to echo "$message"; and it still displayed 'yes' and not '11' in Netscape - since it was the first thing in the script, there wasn't any chance that some other function was changing it.

So it looks like Netscape is not correctly passing the data to the server. Does this sound right? Or is there some magic PHP-level setting that can be changed to make this work correctly?

Thanks,
John
Posted By: Rick Re: Unknown column 'yes' in 'where clause': 1054 - 09/28/2001 1:44 AM
Interesting. Does everything else seem to work ok? It seems that Netscape isn't passing the Number correctly perhaps. I'll need to download Netscape when I get back home and do some testing to see if I can duplicate this and get a fix out.
Yes, everything else seems to be working okay.

More strange info, which makes me even more sure that it's a server problem and not a script problem (but I posted it here to see if anyone had any ideas):

1. The server seemed to go down for a while soon after I was having these problems, and at the same time I shut down the computer and rebooted. After the server came back (and I turned the computer back on), it worked fine in Netscape.

2. Someone else just reported the exact same problem in the exact same place. Only it's in a different instance of the message board system (one that has been running unchanged since February with no such problems). The one I was having problems with this morning is in a different directory, and is a newer version, but from the quick comparison I made of the viewmessage.php files, they are identical (with the exception of some different comments) between the two versions. I don't know if the new problem was with Netscape or IE.

I've now sent a message to my ISP describing the problem, and I'll let you know if they have any ideas.
Some follow-up on this. The other person who reported the same problem was using IE, so I guess it's not a Netscape-specific problem.
Posted By: Rick Re: Unknown column 'yes' in 'where clause': 1054 - 09/29/2001 4:13 AM
Hmm, it's possible you have some database corruption. When contacting your ISP you might want to have them check for any corrupted tables and repair if necessary.
I'll have them check that - thanks.

They also just asked if it is a requirement to have magic quotes on or off.
You don't have to worry about magic quotes as w3t checks that and performs stripslashes on all variables if it is set.
I don't know if "solved" is the correct work, but I found out how to change it in order to eliminate the problem.

I thought after a while that the term "message" might be a reserved word - or something along those lines. This might be why the syntax "&message=123", used to identify the number of the message you wish to view, ended up giving a value of "YES" in the variable $message all the time.

So I changed the name of the variable in the links on the index page for a person's private messages (this is in "viewmessages.php" for the newer version, and "main.inc.php" for the older version that I still work with). It now reads something like "&numofmsg=123". Then on the first line of the "viewmessage.php" script, I put in this line:

$message = $numofmsg;

(instead of changing the name of the $message variable throughout the script)

I'm not sure if my reasoning is correct about why it works, but hey - it works! Even one of my users who has been having lots of problems with this is now reporting error-free private messages.
© UBB.Developers