Ciao ragazzi, ho un problema con la funzione UPDATE. Non riesco ad aggiornare alcuni campi della tabella nel database in quanto mi viene generato un errore e non capisco come risolverlo.
Il seguente è il codice php:
Codice PHP:
<?php    
include("auth.php");    
require(
'db.php');    ini_set('display_errors'1);     
ini_set('log_errors',1);     
error_reporting(E_ALL); 
mysqli_report(MYSQLI_REPORT_ERROR MYSQLI_REPORT_STRICT);
if(isset(
$_POST['update'])) {                        
$user $_SESSION['username'];            
// $selectId = mysqli_query($con,"SELECT id FROM users WHERE username = '$user'");            
// $new_name = $_POST['newname'];            
// $new_lastname = $_POST['newlastname'];            
// $new_birthdate = $_POST['newbirthdate'];            
$name stripslashes($_REQUEST['newname']);             
$name mysqli_real_escape_string($con,$name);            
$lastname stripslashes($_REQUEST['newlastname']);             
$lastname mysqli_real_escape_string($con,$lastname);            
$birthdate stripslashes($_POST['new_birth_year'] . '-' $_POST['new_birth_month'] . '-' $_POST['new_birth_day']);
$queryUpdate "UPDATE `users` SET `name`='$name',`lastname`='$lastname',`birthdate`='$birthdate', WHERE `username`='$user'";        $result mysqli_query($con,$queryUpdate);            
if(
$result){                
echo 
"$id<br>";                
echo 
"data updated";            
}else{                
echo 
"$id<br>";                
echo 
"data not updated";            
}        
}else{
?>
Questo è l'errore che mi genera:

Fatal error: Uncaught exception 'mysqli_sql_exception' with message '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 'WHERE `username`='Davide'' at line 1' in /Applications/XAMPP/xamppfiles/htdocs/form-1/modifyData.php:61 Stack trace: #0 /Applications/XAMPP/xamppfiles/htdocs/form-1/modifyData.php(61): mysqli_query(Object(mysqli), 'UPDATE `users` ...') #1 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/form-1/modifyData.php on line 61