DrivingFail
DrivingFail

Reputation: 43

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use

I keep getting the error:-

"You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'Password='evertonblues' Forename='Josh' Surname='Edmondson' Date of Birth='199' at line 1"

error when running my update query.

$result = mysqli_query($con, "UPDATE Users SET Username='".$newUsername."' Password='".$newPassword."' Forename='".$newForename."' Surname='".$newSurname."' `Date of Birth`='".$newDateofBirth."'     Address='".$newAddress."' `Post Code`='".$newPostcode."' Email='".$newEmail."' `Phone Number`='".$newPhonenumber."' WHERE `User ID`='".$newUserid."';");

Upvotes: 3

Views: 4080

Answers (2)

Apoorv
Apoorv

Reputation: 231

Use query as below:

"UPDATE Users SET `Username`='".$newUsername."', `Password`='".$newPassword."', `Forename`='".$newForename."', `Surname`='".$newSurname."', `Date of Birth`='".$newDateofBirth."', `Address`='".$newAddress."', `Post Code`='".$newPostcode."', `Email`='".$newEmail."', `Phone Number`='".$newPhonenumber."' WHERE `User ID`='".$newUserid."';");

Also space in Date of Birth

Upvotes: 1

Marc B
Marc B

Reputation: 360762

You forgot a bunch of commas:

..snip... SET Username='".$newUsername."' Password='".$newPassw
                                         ^-- and many others

Upvotes: 3

Related Questions