Jump to content

[SOLVED] echoing sql error, but cannot see anything


PC Nerd

Recommended Posts

hi guys....

ive been working on this script, and it was working fine.... however ive added a condition to my SQL, and its stopped working.  im 90% sure the syntax is correct, and i know the values are echoing out fine.....heres the code:

 

$Ind_Messages_SQL = "SELECT * FROM individual_messages WHERE (User_ID = '".$Page_Data['User_ID']."') or (To = '".$Page_Data['User_Name']."')";

 

my output is here:

SELECT * FROM individual_messages WHERE (User_ID = 'correct user_ID') or (To = 'correct_user')

 

and the 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 = 'correct_username')' at line 1

 

if anyone can spot the error, id be most greatful

 

thanks

Link to comment
Share on other sites

Hi PC Nerd your problem is that TO is a reserved word in mysql try this one

 

$Ind_Messages_SQL = "SELECT * FROM individual_messages WHERE (User_ID = '".$Page_Data['User_ID']."') or (`To` = '".$Page_Data['User_Name']."')";

 

Regards

Paul

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.