Still new to this and i have come to a point where i am stuck as i cannot see what is going wrong.
I have a users page, when i click a user it opens a different page which shows user details. If i enter data in the input boxes and click update it runs update_user_data.php which should taken the new data and update the table. This however is not working.
It is returning "Error updating record: 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 'WHERE username= 'jRogers'' at line 1"
Code is below. Please can anyone see where i am going wrong?
<?php
require '../php/config.php';
$usernameold = $_POST["username"];
$emailold = $_POST["email"];
$passwordold = $_POST["password"];
$sql = "UPDATE users SET username='$usernameold', email='$emailold', password='$passwordold', WHERE username= '" .$usernameold."'";
if ($con->query($sql) === TRUE) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . $con->error;
}
?>