I'm having a strange problem with php PDO and mysql. I read other examples here, but while I am learning MySQL with the PDO, I did not understand it and I could not solve it yet.
$name = $_POST[ "name" ];
$email = $_POST[ "email" ];
$telefone = $_POST[ "telefone" ];
$endereco = $_POST[ "endereco" ];
$numero = $_POST[ "numero" ];
$bairro = $_POST[ "bairro" ];
$cidade = $_POST[ "cidade" ];
$telefoneHash = make_hash( $telefone );
$PDO = db_connect();
//$PDO->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
//With this code it gives the error: 'Syntax error or access violation: 1064'
//Without it it does not give an error but does not perform the update
$PDO = $PDO->prepare( 'UPDATE users SET :name, :email, :telefone, :endereco, :numero, :bairro, :cidade WHERE email = :email' );
$PDO->bindValue( ':name', $_REQUEST[ 'name' ] );
$PDO->bindValue( ':email', $_REQUEST[ 'email' ] );
$PDO->bindValue( ':telefone', $telefoneHash );
$PDO->bindValue( ':endereco', $_REQUEST[ 'endereco' ] );
$PDO->bindValue( ':numero', $_REQUEST[ 'numero' ] );
$PDO->bindValue( ':bairro', $_REQUEST[ 'bairro' ] );
$PDO->bindValue( ':cidade', $_REQUEST[ 'cidade' ] );
$PDO->execute();
echo $PDO->rowCount() . " records UPDATED successfully";
UPDATEsyntax is the same as yours?$_REQUESTif your variables are set at the top of the page.INSERT instead of an UPDATE. With awhereclause? Lack of coffee again?executecall with an associative array that has all the values, that helps cut down on how much code you have to write.