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

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

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.