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