$dsn = 'mysql:dbname=timer;host=127.0.0.1';
$user = 'root';
$password = '';
$update=$_COOKIE['name'];
$query = 'UPDATE user SET password='2' WHERE username=(?)';
try {
$dbh = new PDO($dsn, $user, $password);
$dbh->prepare( $query )->execute( array($query) );
} catch (PDOException $e) {
echo 'Connection failed ' . $e->getMessage();
}
Can't be sure if it works because I don't know what you have in your $_COOKIE array.
But the code should look like this.
For security, you can add some text transformation to the variable $update like addslashes or other ones.