lional Posted July 3, 2007 Share Posted July 3, 2007 Hi All I have been battling with an insert query, but only on one table. Here is my error message followed by the code snippet Failed1064: 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 'select, select_day, select_month, select_year, sem, sem_day, sem_month, sem_year' at line 1 $query_deg_in = "INSERT INTO cc_degrees (member_no, royal, royal_day, royal_month, royal_year, select, select_day, select_month, select_year, sem, sem_day, sem_month, sem_year, masterlodge)VALUES('$member_no_out','$com_royal_out','$royal_day_out','$royal_month_out','$royal_year_out','$com_select_out','$select_day_out','$select_month_out','$select_year_out','$com_sem_out','$sem_day_out','$sem_month_out','$sem_year_out','$master_lodge_out')"; $result_deg_in = mysql_query ($query_deg_in); Thanks Lional Link to comment https://forums.phpfreaks.com/topic/58273-error-in-mysql/ Share on other sites More sharing options...
AndyB Posted July 3, 2007 Share Posted July 3, 2007 SELECT is a MySQL reserved word. Avoid using reserved words for field or table names. http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html Link to comment https://forums.phpfreaks.com/topic/58273-error-in-mysql/#findComment-288952 Share on other sites More sharing options...
Illusion Posted July 3, 2007 Share Posted July 3, 2007 how it is allowed while creating the table. Link to comment https://forums.phpfreaks.com/topic/58273-error-in-mysql/#findComment-288955 Share on other sites More sharing options...
AndyB Posted July 3, 2007 Share Posted July 3, 2007 how it is allowed while creating the table. Perhaps because of the way you create your tables. There's nothing to stop you using reserved words - unless working code is one of your objectives. The sloppy workaround is `backticks` Link to comment https://forums.phpfreaks.com/topic/58273-error-in-mysql/#findComment-288957 Share on other sites More sharing options...
rameshfaj Posted July 4, 2007 Share Posted July 4, 2007 $query_deg_in = "INSERT INTO cc_degrees (member_no, royal, royal_day, royal_month, royal_year, select, select_day, select_month, select_year, sem, sem_day, sem_month, sem_year, masterlodge)VALUES('$member_no_out','$com_royal_out','$royal_day_out','$royal_month_out','$royal_year_out','$com_select_out','$select_day_out','$select_month_out','$select_year_out','$com_sem_out','$sem_day_out','$sem_month_out','$sem_year_out','$master_lodge_out')"; $result_deg_in = mysql_query ($query_deg_in); Use like this: $query_deg_in = "INSERT INTO cc_degrees (`member_no`, `royal`, `royal_day`, `royal_month`, `royal_year`, `select`, `select_day`,...)VALUES('$member_no_out','$com_royal_out','$royal_day_out','$royal_month_out','$royal_year_...)"; Link to comment https://forums.phpfreaks.com/topic/58273-error-in-mysql/#findComment-289289 Share on other sites More sharing options...
fenway Posted July 10, 2007 Share Posted July 10, 2007 Use like this: $query_deg_in = "INSERT INTO cc_degrees (`member_no`, `royal`, `royal_day`, `royal_month`, `royal_year`, `select`, `select_day`,...)VALUES('$member_no_out','$com_royal_out','$royal_day_out','$royal_month_out','$royal_year_...)"; NO... don't -- change the column name. Link to comment https://forums.phpfreaks.com/topic/58273-error-in-mysql/#findComment-294613 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.