Jump to content

[SOLVED] mysql update syntax help


nbarone

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.