Requete preparé PHP erreur

schancel Messages postés 296 Date d'inscription   Statut Membre Dernière intervention   -  
schancel Messages postés 296 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
je ne comprend pas pourquoi je recoi toujour le message d'erreur
suivant

PDOStatement::execute() expects at most 1 parameter, 5 given in C:\wamp\www\Test\sbs.php on line 81
voici mon code :
try{
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bddz = new PDO('mysql:host=localhost;dbname=sbdb', 'root', '',$pdo_options);
$reqz = $bddz->prepare('INSERT INTO sbtable(email,password,confirm,nom,prenom) VALUES(?,?,?,?,?)');
$reqz->execute(array ($_POST['email']) ,($_POST['pass']) ,($_POST['confirm']) , ($_POST['nom']) ,($_POST['prenom']) );

$reqz->closeCursor();
}
catch(exCeption $e)
{
die('Erreur : '.$e->getMessage());
}

1 réponse

  1. avion-f16 Messages postés 19182 Date d'inscription   Statut Contributeur Dernière intervention   4 511
     
    Salut,

    $reqz->execute(array ($_POST['email']) ,($_POST['pass']) ,($_POST['confirm']) , ($_POST['nom']) ,($_POST['prenom']) );

    La syntaxe est incorrecte.
    Ici, tu donnes 5 arguments : un array contenant seulement l'email, et 4 autres variables seules (en-dehors de l'array).

    Le script n'attend qu'un seul argument : un array contenant l'ensemble des variables.

    $reqz->execute(array(
        $_POST['email'],
        $_POST['pass'],
        $_POST['confirm'],
        $_POST['nom'],
        $_POST['prenom'])
    );
    0
    1. schancel Messages postés 296 Date d'inscription   Statut Membre Dernière intervention   49
       
      merciiiiiiiiiiiiiiiii
      0