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 Link to comment https://forums.phpfreaks.com/topic/54959-solved-echoing-sql-error-but-cannot-see-anything/ 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 Link to comment https://forums.phpfreaks.com/topic/54959-solved-echoing-sql-error-but-cannot-see-anything/#findComment-271766 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. Link to comment https://forums.phpfreaks.com/topic/54959-solved-echoing-sql-error-but-cannot-see-anything/#findComment-271767 Share on other sites More sharing options...
PC Nerd Posted June 10, 2007 Author Share Posted June 10, 2007 thanks working c y a Link to comment https://forums.phpfreaks.com/topic/54959-solved-echoing-sql-error-but-cannot-see-anything/#findComment-271768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.