This UPDATE script works:
$query = $pdo->prepare("UPDATE posts SET headline = ? WHERE id = ?");
$query->bindValue("1", $_POST['headline']);
$query->bindValue("2", "2");
$query->execute();
Though, this INSERT script does not work:
$query = $pdo->prepare("INSERT INTO posts (headline, post) VALUES (?, ?)");
$query->bindValue("1", $_POST['headline']);
$query->bindValue("2", $_POST['post']);
$query->execute();
Nothing gets added, when executing this script.
The connection:
<?php
$dsn = "mysql:dbname=phpblog;host=localhost";
$user = "root";
$password = "";
try{
$pdo = new PDO($dsn, $user, $password);
}catch(PDOException $e){
echo "Connection failed: " . $e->getMessage();
}
?>
Any suggestions why the INSERT script is not working?