PC Nerd Posted June 10, 2007 Share Posted June 10, 2007 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 Quote Link to comment Share on other sites More sharing options...
paul2463 Posted June 10, 2007 Share Posted June 10, 2007 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 Quote Link to comment Share on other sites More sharing options...
AndyB Posted June 10, 2007 Share Posted June 10, 2007 to is a reserved word - http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html Avoid using reserved words as column/field names or table names. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted June 10, 2007 Author Share Posted June 10, 2007 thanks working c y a Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.