SQL Update returning error message : <p>Still new to this and i have come to a point where i am stuck as i cannot see what is going wrong. </p>

<p>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. </p>

<p>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"</p>

<p>Code is below. Please can anyone see where i am going wrong?</p>

<pre><code>&lt;?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-&gt;query($sql) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $con-&gt;error;
}

?&gt;
</code></pre>
