( ! ) Notice: Undefined variable: dd in C:\wamp\www\Debutant\commentaires_post.php on line 23
( ! ) Fatal error: Uncaught Error: Call to a member function prepare() on null in C:\wamp\www\Debutant\commentaires_post.php on line 23
( ! ) Error: Call to a member function prepare() on null in C:\wamp\www\Debutant\commentaires_post.php on line 23
line 23 : $req = $dd->prepare('INSERT INTO commentaires (auteur,commentaire) VALUES (? , ?)');
,
voici le code de l page commentaires.php :
<!DOCTYPE html>
<html>
<head>
<title> Page d'envoi du Formulaire </title>
</head>
<body>
<?php
try
{
$bdd = new PDO('mysql:host=localhost;dbname=blog','root','',array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
}
catch(Exception $e)
{
die('erreur : ' . $e->getMessage() ) ;
}
$req = $dd->prepare('INSERT INTO commentaires (auteur,commentaire) VALUES (? , ?)');
$req -> execute(array($_POST['auteur'],$_POST['commentaire']));
header('location: commantaires.php');
?>
</body>
</html>