Hello,

Bonne année à tous !
Je dois être fatigué, mais impossible de voir d'où vient mon erreur ...

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
require 'includes/connect_bdd.php'; // connection à la base de données
if(session_status() == PHP_SESSION_NONE){
    session_start();
}
 
foreach($_POST as $key => $val) echo '$_POST["'.$key.'"]='.$val.'<br />'; 
 
// Ajout d'une prestation
 
if (isset($_POST['nom_prestation']) AND isset($_POST['codage_prestation']) AND isset($_POST['montant_sans_hn']) AND isset($_POST['montant_hn']) AND !isset($_POST['id_prestation'])) {
 
	$nom_prestation = htmlspecialchars($_POST['nom_prestation']);
	$codage_prestation = htmlspecialchars($_POST['codage_prestation']);
	$montant_sans_hn = htmlspecialchars($_POST['montant_sans_hn']);
	$montant_hn = htmlspecialchars($_POST['montant_hn']);
 
	$req = $bdd->prepare('INSERT INTO prestations(nom, codage, montant_hn, montant_sans_hn) VALUES(:nom_prestation, :codage_prestation, :montant_hn, :montant_sans_hn)');
 
    $req->execute(array(
 
        'nom' => $nom_prestation,
 
        'codage' => $codage_prestation,
 
        'montant_hn' => $montant_hn,
 
        'montant_sans_hn' => $montant_sans_hn
 
        ));
    $req->closeCursor(); // termine le traitement de la requête    
 
    $_SESSION['flash']['success'] = 'Prestation ajoutés à la base de données';
    header('Location: parametres.php');
    exit();
 
}
J'obtiens ce message d'erreur :

PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\wamp64\www\New17VH\parametres-post.php on line 28


Est-ce que vous voyez une erreur quelque part ?

Merci beaucoup pour votre aide.