Warning: PDOStatement::execute(): SQLSTATE[42000]: Syntax error or access violation: 1064 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 'SET user_surname = 'name', SET user_sprat = '1234567'' at line 3 i
//the query to run
$sql = "UPDATE user
SET user_firstname = ?,
SET user_surname = ?,
SET user_sprat = ?,
SET user_country = ?,
SET user_telephone = ?,
SET user_mobile = ?,
SET user_contactemail = ?,
SET user_introduction = ?
WHERE user_id = ?
AND user_enabled=1";
//run the query
$database = DatabaseFactory::getFactory()->getConnection();
$update_profile = $database->prepare($sql);
$update_profile->execute(array($firstname, $surname, $sprata, $country, $telephone, $mobile, $email, $introduction,Session::get('id')));
I get that error, I'm not sure why, any help would be great all my tables are named correctly to my knowledge
The correct SQL syntax for an update query is UPDATE table SET rowA = value, rowB = value
Notice SET
was mentioned once and commas used to separate the rows.
EG:
$sql = "UPDATE user SET
user_firstname = ?,
user_surname = ?,
user_sprat = ?,
user_country = ?,
user_telephone = ?,
user_mobile = ?,
user_contactemail = ?,
user_introduction = ?
WHERE user_id = ?
AND user_enabled=1";
Reference: