Jump to content

Weird sql query problem


Payback451

Recommended Posts

I've spent quite a bit of time looking at this for the problem, and i'm completely stumped.

$Messages = mysql_query("SELECT * FROM pm WHERE to = $UserInfo[id]") or die(mysql_error());
while($Message = mysql_fetch_array($Messages)) {
[display code- no problems here]
}

Produces the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to = 1' at line 1

$UserInfo[id] is properly set to the number 1. There are 3 entries in the table pm that should be selected. Why is this producing an error? This has also happened in several other places in my script.. and the code is fine as far as I and my other coder friends can see. Was there some major update to the way mysql and php interact that would cause this to give a sytnax error? Because i have never experienced anything like this in the past.

Also, to save you all time, i've tried putting the $UserInfo[id] in quotes, tried using mysql_fetch_row, tried changing the variable name, tried selecting specific fields instead of *, tried renaming the table, and some more.

Thanks very much for your help.
Link to comment
https://forums.phpfreaks.com/topic/12212-weird-sql-query-problem/
Share on other sites

Archived

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

×
×
  • 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.