I have this simple insert into query that seems to be outputting an error I cannot find and it's driving me nuts:(
would someone help me.
error is:
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 `User_Id`='16'' at line 1
Query is:
$insert = "INSERT INTO `pf_users` (`Task4`,`Task5`,`Task6`,`Task7`) VALUES ('$task4','$task5','$task6','$task7') WHERE `User_Id`='$GetUser'";
And here is the php code:
if(empty($_POST) === false) {
$task4 = sanitize($_POST['task4']);
$task5 = sanitize($_POST['task5']);
$task6 = sanitize($_POST['task6']);
$task7 = sanitize($_POST['task7']);
$GetUser = $_SESSION['User_Id'];
//Query not inserting into database
$insert = "INSERT INTO `pf_users` (`Task4`,`Task5`,`Task6`,`Task7`) VALUES ('$task4','$task5','$task6','$task7') WHERE `User_Id`='$GetUser'";
echo "<pre>".$insert."</pre>";
mysql_query($insert) or die(mysql_error());
}
Sanitize function is mysql_real_escape_string() and the $task values are receiving the form data.
Thanks.
You have an error in your SQL syntax;means that you HAVE an error in your SQL syntax, then it's useless to search further.