nbarone Posted March 24, 2009 Share Posted March 24, 2009 This is what I have: $query = "UPDATE vol_app SET app_sunday_vols='$sunday_choices', app_other_vols='$week_choices', app_children='$vapp_childrenYN', app_numchildren='$vapp_childrenNum', app_service_attended='$vapp_service_attended, app_vol_service='$vapp_service_avail' WHERE 'app_id'='$insert_id'"; $result = mysql_query($query) or die (mysql_error()); output: 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 '11' WHERE 'app_id'='13'' at line 1 thanks in advanced! Link to comment https://forums.phpfreaks.com/topic/150907-solved-mysql-update-syntax-help/ Share on other sites More sharing options...
lonewolf217 Posted March 24, 2009 Share Posted March 24, 2009 'app_id' should use backticks, not quotes `app_id` Link to comment https://forums.phpfreaks.com/topic/150907-solved-mysql-update-syntax-help/#findComment-792753 Share on other sites More sharing options...
nbarone Posted March 24, 2009 Author Share Posted March 24, 2009 'app_id' should use backticks, not quotes `app_id` that didn't fix it, but can you explain why I should use them instead? Link to comment https://forums.phpfreaks.com/topic/150907-solved-mysql-update-syntax-help/#findComment-792755 Share on other sites More sharing options...
PFMaBiSmAd Posted March 24, 2009 Share Posted March 24, 2009 Back-ticks are mysql specific and should be avoided. For your specific query, nothing should be around app_id Echo $query to see what it actually contains. Link to comment https://forums.phpfreaks.com/topic/150907-solved-mysql-update-syntax-help/#findComment-792758 Share on other sites More sharing options...
kickstart Posted March 24, 2009 Share Posted March 24, 2009 Hi You use back ticks around column names which may not be obvious column names. For example those with spaces in them or those which are an SQL reserved word. You use quotation marks around strings, so WHERE 'app_id'='$insert_id'" is checking to see if a string app_id is equal to $insert_id, while WHERE `app_id`='$insert_id'" is checking if a column called app_id is equal to $insert_id. As to your issue, echo out $query before you execute it and check what it is. All the best Keith Link to comment https://forums.phpfreaks.com/topic/150907-solved-mysql-update-syntax-help/#findComment-792759 Share on other sites More sharing options...
nbarone Posted March 24, 2009 Author Share Posted March 24, 2009 thanks, I forgot a ' around a variable thank you all for the quick help! Link to comment https://forums.phpfreaks.com/topic/150907-solved-mysql-update-syntax-help/#findComment-792766 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.