aeboi80 Posted July 7, 2010 Share Posted July 7, 2010 For the life of me I cannot figure out what I have mistyped. I am trying to do a simple UPDATE query. Here is the error which I am getting: 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 '(`first_name`, `last_name`, `email`, `address1`, `address2`, `city`, `stat' at line 1 Here is the PHP and SQL statement: $firstName = ucwords(protect($_POST['first_name'])); $lastName = ucwords(protect($_POST['last_name'])); $email = protect($_POST['email']); $address1 = ucwords(protect($_POST['address1'])); $address2 = protect($_POST['address2']); $city = protect($_POST['city']); $state = protect($_POST['state']); $zip = protect($_POST['zip']); $country = protect($_POST['country']); $phone = protect($_POST['phone']); $res2 = mysql_query("UPDATE ".DB_TABLE_PREFIX . "members SET(`first_name`, `last_name`, `email`, `address1`, `address2`, `city`, `state`, `zip`, `country`, `phone`) VALUES('".$firstName."','".$lastName."','".$email."','".$address1."','".$address2."','".$city."','".$state."', '".$zip."','".$country."','".$phone."') WHERE username = '".$_SESSION['loggedin_username']."'") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/207050-mysql-update-error/ Share on other sites More sharing options...
marcus Posted July 7, 2010 Share Posted July 7, 2010 That's the wrong syntax for an update query. $sql = "UPDATE `table` SET `field`='".$field1."' , `field2`='".$field2."' WHERE `this`='".$that."'"; Link to comment https://forums.phpfreaks.com/topic/207050-mysql-update-error/#findComment-1082661 Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2010 Share Posted July 7, 2010 You're using INSERT syntax with an UPDATE query . . . UPDATE `table` SET `field1` = 'value1', `field12`= 'value2', `field3` = 'value3' etc. Link to comment https://forums.phpfreaks.com/topic/207050-mysql-update-error/#findComment-1082665 Share on other sites More sharing options...
aeboi80 Posted July 7, 2010 Author Share Posted July 7, 2010 Thank you guys ! Link to comment https://forums.phpfreaks.com/topic/207050-mysql-update-error/#findComment-1082698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.