Bonjour,
J'ai la fonction suivante:Cette fonction renvoie à la ligne 11 une erreur PDO:
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 function createAbo($toSave) { global $db; var_dump($toSave); $query = " INSERT IGNORE INTO dat_abonnes(pseudo, client_nom, courriel, contact_nom, contact_prenom, adresse1, adresse2, cp, ville, pays, banni, init_abo, date_creation) VALUES(:pseudo, :client_nom, :courriel, :contact_nom, :contact_prenom, :adresse1, :adresse2, :cp, :ville, :pays, :banni, :init_abo, :date_creation) ;"; $result = $db->prepare($query); $result->execute($toSave); if ($result->rowCount()) $_SESSION['admin']['id_abo'] = $db->lastInsertId(); return $result->rowCount(); }Le var_dump de la ligne 3 donne ceci:
Code : Sélectionner tout - Visualiser dans une fenêtre à part Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in ...Je pense que le problème vient de la clef primaire (id). Pourtant j'ai lu qu'elle n'était pas nécessaire lorsque cette clef était en auto-incrément, ce qui est bien le cas.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 array (size=13) 'pseudo' => string 'xxxxxx' (length=6) 'client_nom' => string 'Test' (length=4) 'courriel' => string 'test@test.ch' (length=12) 'contact_nom' => string 'Toto' (length=4) 'contact_prenom' => string 'Tata' (length=4) 'adresse1' => string 'rue du Lac 12' (length=13) 'adresse2' => string '' (length=0) 'cp' => string '1200' (length=4) 'ville' => string 'Nyon' (length=4) 'pays' => string 'CH' (length=2) 'init_abo' => string '' (length=0) 'banni' => int 0 'creation' => string '2017-06-16' (length=10)
Partager