atticus Posted December 20, 2007 Share Posted December 20, 2007 I am getting syntax error for the following code. I can't seem to find the problem: Error, insert query failedYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order (cust_id, last_name, first_name, middle_name, suffix, address_1, address_2' at line 1 $query = "INSERT INTO order (cust_id, last_name, first_name, middle_name, suffix, address_1, address_2, city, state, zip, gender, race, dob, ssn, search_area_state, search_area_county, city_search, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, type_service, notes) VALUES ('$cust_id', '$last_name', '$first_name', '$middle_name', '$suffix', '$address1', '$address2', '$city', '$state', '$zip', '$gender', '$race', '$dob', '$ssn', '$search_area_state', '$search_area_county','$city_search', '$s1', '$s2', '$s3', '$s4', '$s5', '$s6', '$s7', '$s8', '$s9', '$s10', '$s11', '$s12', '$s13', '$s14', '$s15', '$type_service', '$notes');"; mysql_query($query) or die('Error, insert query failed' . mysql_error()); Link to comment https://forums.phpfreaks.com/topic/82559-solved-mysql-insert-problem/ Share on other sites More sharing options...
revraz Posted December 20, 2007 Share Posted December 20, 2007 ORDER is a reserved word. Either use `backticks` or change it. Changing it would be better. Link to comment https://forums.phpfreaks.com/topic/82559-solved-mysql-insert-problem/#findComment-419718 Share on other sites More sharing options...
Caesar Posted December 20, 2007 Share Posted December 20, 2007 Edit: Above feller beat me to it...use `ticks`. Link to comment https://forums.phpfreaks.com/topic/82559-solved-mysql-insert-problem/#findComment-419720 Share on other sites More sharing options...
atticus Posted December 20, 2007 Author Share Posted December 20, 2007 thanks...I have never tried to change the name of a table in phpmyadmin and I don't see how. The back ticks aren't making a difference Link to comment https://forums.phpfreaks.com/topic/82559-solved-mysql-insert-problem/#findComment-419725 Share on other sites More sharing options...
revraz Posted December 20, 2007 Share Posted December 20, 2007 Post the updated code Link to comment https://forums.phpfreaks.com/topic/82559-solved-mysql-insert-problem/#findComment-419727 Share on other sites More sharing options...
revraz Posted December 20, 2007 Share Posted December 20, 2007 You can use the ALTER sql function to change it. http://dev.mysql.com/doc/refman/5.0/en/alter-table.html Link to comment https://forums.phpfreaks.com/topic/82559-solved-mysql-insert-problem/#findComment-419729 Share on other sites More sharing options...
atticus Posted December 20, 2007 Author Share Posted December 20, 2007 I found the alter command...appreciate it everybody Link to comment https://forums.phpfreaks.com/topic/82559-solved-mysql-insert-problem/#findComment-419730 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.