IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Erreur de requête du a un nombre


Sujet :

PHP & Base de données

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2011
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2011
    Messages : 62
    Par défaut Erreur de requête du a un nombre
    Bonjour a tous,
    Je n'arrive pas a trouvé l'erreur que me retourne la console.

    erreur : Invalid parameter number: number of bound variables does not match number of tokens

    code :

    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
     
    	$candidat = $connexion -> prepare("INSERT INTO candidats SET nom=:nom, prenom=:prenom, adresse=:adresse, departement=:departement, email=:email', tel=:tel, date=:date, sit_fam=:sit_fam, age=:age, formation=:formation, experience=:experience, langue=:langue, divers=:divers, cv=:cv, poste=:poste, poste2=:poste2, poste3=:poste3', poste4=:poste4, 1departement=:1departement, 1departement2=:1departement2, 1departement3=:1departement3, 1departement4=:1departement4, 1region=:1region, id_user=:id_user, preavis=:preavis, salaire=:salaire, commentaire=:commentaire, gestion=:gestion, produits=:produits, management=:management, divers_eval=:divers_eval ");
    	$candidat -> bindParam('nom', $_POST['nom']);
    	$candidat -> bindParam('prenom', $_POST['prenom']);
    	$candidat -> bindParam('adresse', $_POST['adresse']);
    	$candidat -> bindParam('departement', $_POST['dept'], PDO::PARAM_INT);
    	$candidat -> bindParam('email', $_POST['email']);
    	$candidat -> bindParam('tel', $_POST['tel'], PDO::PARAM_INT);
    	$candidat -> bindParam('date', date('Y,m,d'));
    	$candidat -> bindParam('sit_fam', $_POST['sit_fam']);
    	$candidat -> bindParam('age', $_POST['jour'], PDO::PARAM_INT);
    	$candidat -> bindParam('formation', $_POST['forma']);
    	$candidat -> bindParam('experience', $_POST['expe']);
    	$candidat -> bindParam('langue', $_POST['langue']);
    	$candidat -> bindParam('divers', $_POST['divers']);
    	$candidat -> bindParam('cv', $_POST['cv']);
    	$candidat -> bindParam('poste', $_POST['poste']);
    	$candidat -> bindParam('poste2', $_POST['poste2'], PDO::PARAM_INT);
    	$candidat -> bindParam('poste3', $_POST['poste3'], PDO::PARAM_INT);
    	$candidat -> bindParam('poste4', $_POST['poste4'], PDO::PARAM_INT);
    	$candidat -> bindParam('1departement', $_POST['dept'], PDO::PARAM_INT);
    	$candidat -> bindParam('1departement2', $_POST['dept2'], PDO::PARAM_INT);
    	$candidat -> bindParam('1departement3', $_POST['dept3'], PDO::PARAM_INT);
    	$candidat -> bindParam('1departement4', $_POST['dept4'], PDO::PARAM_INT);
    	$candidat -> bindParam('1region', $_POST['region'], PDO::PARAM_INT);
    	$candidat -> bindParam('id_user', $_SESSION['admin_id'], PDO::PARAM_INT);
    	$candidat -> bindParam('preavis', $_POST['preavis']);
    	$candidat -> bindParam('salaire', $_POST['salaire'], PDO::PARAM_INT);
    	$candidat -> bindParam('commentaire', $_POST['divers']);
    	$candidat -> bindParam('gestion', $_POST['gestion']);
    	$candidat -> bindParam('produits', $_POST['produits']);
    	$candidat -> bindParam('management', $_POST['management']);
    	$candidat -> bindParam('divers_eval', $_POST['com'], PDO::PARAM_INT);
    	$candidat -> execute();
    Le deuxième soucis concerne l'upload. si quelqu'un voit une erreur sa serait sympas si jamais je trouve la solutions je passe vous informer. concernant l'upload il me dit que l'extenssion du fichier est invalide.

    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
     
    $nomOrigine = $_FILES['cv']['name'];
    	echo $nomOrigine.'/';
    	$elementsChemin = pathinfo($nomOrigine);
    	echo $elementsChemin.'/';
    	$extensionFichier = $elementsChemin['extension'];
    	echo $extensionFichier.'/';
    	$extensionsAutorisees = array('PDF', 'pdf', 'doc');
    				if (!(in_array($extensionFichier, $extensionsAutorisees))) 
    					{
       					echo '<div class="notification error png_bg"><div>Le fichier n\'a pas l\'extension attendue, <a href="#">Retour</a></div></div>';
    					}
    					else
    						{
    						$repertoireDestination = 'répertoire de destination';
        					$nomDestination = ''.$nombre.'_'.clean_url($article_titre).'.'.$extensionFichier.'';
    						move_uploaded_file($_FILES["cv"]["tmp_name"],$repertoireDestination.$nomDestination);
     
    						echo '<div class="bo_sign">
    							<center>Le candidat à bien été ajouté <a href="#">retour</a></center>
    		 				 </div>';
    						}

  2. #2
    Expert confirmé
    Avatar de rawsrc
    Homme Profil pro
    Dev indep
    Inscrit en
    Mars 2004
    Messages
    6 142
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev indep

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 142
    Billets dans le blog
    12
    Par défaut
    Citation Envoyé par le nOoB Voir le message
    Bonjour a tous,
    Je n'arrive pas a trouvé l'erreur que me retourne la console.

    erreur : Invalid parameter number: number of bound variables does not match number of tokens
    Regardes dans ta chaine SQL à ces endroits Tu as des ' qui trainent.

  3. #3
    Expert confirmé
    Avatar de rawsrc
    Homme Profil pro
    Dev indep
    Inscrit en
    Mars 2004
    Messages
    6 142
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev indep

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 142
    Billets dans le blog
    12
    Par défaut
    Citation Envoyé par le nOoB Voir le message
    Le deuxième soucis concerne l'upload. si quelqu'un voit une erreur sa serait sympas si jamais je trouve la solutions je passe vous informer. concernant l'upload il me dit que l'extenssion du fichier est invalide.
    Je pense que tu n'as pas prévu tous les cas de figures entre les minuscules et majuscules dans le tableau des extensions autorisées :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    $extensionsAutorisees = array('PDF', 'DOC');
    if ( ! in_array(strtoupper($extensionFichier), $extensionsAutorisees)) {

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2011
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2011
    Messages : 62
    Par défaut
    J'ais fait les modification mais pas de réel changement :

    erreur retourné : le fichier n'a pas l'extension attendue et Invalid parameter number: number of bound variables does not match number of tokens

    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
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
     
    	$candidat = $connexion -> prepare("INSERT INTO candidats SET nom=:nom, prenom=:prenom, adresse=:adresse, departement=:departement, email=:email, tel=:tel, date=:date, sit_fam=:sit_fam, age=:age, formation=:formation, experience=:experience, langue=:langue, divers=:divers, cv=:cv, poste=:poste, poste2=:poste2, poste3=:poste3, poste4=:poste4, 1departement=:1departement, 1departement2=:1departement2, 1departement3=:1departement3, 1departement4=:1departement4, 1region=:1region, id_user=:id_user, preavis=:preavis, salaire=:salaire, commentaire=:commentaire, gestion=:gestion, produits=:produits, management=:management, divers_eval=:divers_eval ");
    	$candidat -> bindParam('nom', $_POST['nom']);
    	$candidat -> bindParam('prenom', $_POST['prenom']);
    	$candidat -> bindParam('adresse', $_POST['adresse']);
    	$candidat -> bindParam('departement', $_POST['dept'], PDO::PARAM_INT);
    	$candidat -> bindParam('email', $_POST['email']);
    	$candidat -> bindParam('tel', $_POST['tel'], PDO::PARAM_INT);
    	$candidat -> bindParam('date', date('Y,m,d'));
    	$candidat -> bindParam('sit_fam', $_POST['sit_fam']);
    	$candidat -> bindParam('age', $_POST['jour'], PDO::PARAM_INT);
    	$candidat -> bindParam('formation', $_POST['forma']);
    	$candidat -> bindParam('experience', $_POST['expe']);
    	$candidat -> bindParam('langue', $_POST['langue']);
    	$candidat -> bindParam('divers', $_POST['divers']);
    	$candidat -> bindParam('cv', $_POST['cv']);
    	$candidat -> bindParam('poste', $_POST['poste']);
    	$candidat -> bindParam('poste2', $_POST['poste2'], PDO::PARAM_INT);
    	$candidat -> bindParam('poste3', $_POST['poste3'], PDO::PARAM_INT);
    	$candidat -> bindParam('poste4', $_POST['poste4'], PDO::PARAM_INT);
    	$candidat -> bindParam('1departement', $_POST['dept'], PDO::PARAM_INT);
    	$candidat -> bindParam('1departement2', $_POST['dept2'], PDO::PARAM_INT);
    	$candidat -> bindParam('1departement3', $_POST['dept3'], PDO::PARAM_INT);
    	$candidat -> bindParam('1departement4', $_POST['dept4'], PDO::PARAM_INT);
    	$candidat -> bindParam('1region', $_POST['region'], PDO::PARAM_INT);
    	$candidat -> bindParam('id_user', $_SESSION['admin_id'], PDO::PARAM_INT);
    	$candidat -> bindParam('preavis', $_POST['preavis']);
    	$candidat -> bindParam('salaire', $_POST['salaire'], PDO::PARAM_INT);
    	$candidat -> bindParam('commentaire', $_POST['divers']);
    	$candidat -> bindParam('gestion', $_POST['gestion']);
    	$candidat -> bindParam('produits', $_POST['produits']);
    	$candidat -> bindParam('management', $_POST['management']);
    	$candidat -> bindParam('divers_eval', $_POST['com'], PDO::PARAM_INT);
    	$candidat -> execute();
     
    	// Uplod du cv dans ../Upload/cv/
    	$nomOrigine = $_FILES['cv']['name'];
    	echo $nomOrigine.'/';
    	$elementsChemin = pathinfo($nomOrigine);
    	echo $elementsChemin.'/';
    	$extensionFichier = $elementsChemin['extension'];
    	echo $extensionFichier.'/';
    	$extensionsAutorisees = array('PDF', 'pdf', 'doc');
    				if (! in_array(strtoupper($extensionFichier), $extensionsAutorisees)) 
    					{
       					echo '<div class="bo_sign"><center>Le fichier n\'a pas l\'extension attendue, <a href="#">Retour</a></center></div>';
    					}
    					else
    						{
    						$repertoireDestination = 'chemin fichier';
        					$nomDestination = ''.$nombre.'_'.clean_url($article_titre).'.'.$extensionFichier.'';
    						move_uploaded_file($_FILES["cv"]["tmp_name"],$repertoireDestination.$nomDestination);
     
    						echo '<div class="bo_sign">
    							<center>Le candidat à bien été ajouté <a href="#">retour</a></center>
    		 				 </div>';
    						}

  5. #5
    Expert confirmé
    Avatar de rawsrc
    Homme Profil pro
    Dev indep
    Inscrit en
    Mars 2004
    Messages
    6 142
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev indep

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 142
    Billets dans le blog
    12
    Par défaut
    Est-ce-que tu es absolument sûr que toutes les valeurs attendues sont dans le tableau $_POST ?
    Est-ce-que echo $extensionFichier.'/'; te renvoie bien une extension ?

  6. #6
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2011
    Messages
    62
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2011
    Messages : 62
    Par défaut
    J'ais trois echo du avec un séparateur /

    voila le retour des trois echo /Array//

  7. #7
    Expert confirmé
    Avatar de rawsrc
    Homme Profil pro
    Dev indep
    Inscrit en
    Mars 2004
    Messages
    6 142
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev indep

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 142
    Billets dans le blog
    12
    Par défaut
    Citation Envoyé par le nOoB Voir le message
    J'ais trois echo du avec un séparateur /

    voila le retour des trois echo /Array//
    ça veut dire que ton fichier n'existe pas. Tu n'as que les slashs que t'as concaténé aux valeurs de pathinfo($nomOrigine);La conséquence logique est que tu ne peux pas avoir d'extension de fichier vu que le fichier est inexistant.

  8. #8
    Membre Expert Avatar de RunCodePhp
    Profil pro
    Inscrit en
    Janvier 2010
    Messages
    2 962
    Détails du profil
    Informations personnelles :
    Localisation : Réunion

    Informations forums :
    Inscription : Janvier 2010
    Messages : 2 962
    Par défaut
    Salut

    La syntaxe que tu utilise pour faire une insertion n'est pas bonne (sauf erreur).
    (c'est un mélange d'un INSERT et d'un UPDATE).

    La syntaxe c'est théoriquement comme ceci :
    Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    INSERT INTO
    nom_table (champ1, champ2, champN)
    VALUES (val1, val2, valN)
    Puis aussi, le nombre de champs renseigné (champ1, champ2) DOIT être le même que le nombre de valeurs dans le VALUES (valeur_champ1, valeur_champ2)
    Si le nombre (couple : renseigné/valeur) n'est pas concordant, alors ça va générer une erreur genre : number of bound variables does not match number of tokens, que tu as.

    Le nombre de champs renseignées :
    1/ nom=:nom
    2/ prenom=:prenom
    3/ adresse=:adresse
    4/ departement=:departement
    5/ email=:email, tel=:tel
    6/ date=:date
    7/ sit_fam=:sit_fam
    8/ age=:age
    9/ formation=:formation
    10/ experience=:experience
    11/ langue=:langue
    12/ divers=:divers
    13/ cv=:cv
    14/ poste=:poste
    15/ poste2=:poste2
    16/ poste3=:poste3
    17/ poste4=:poste4
    18/ 1departement=:1departement
    19/ 1departement2=:1departement2
    20/ 1departement3=:1departement3
    21/ 1departement4=:1departement4
    22/ 1region=:1region
    23/ id_user=:id_user
    24/ preavis=:preavis
    25/ salaire=:salaire
    26/ commentaire=:commentaire
    27/ gestion=:gestion
    28/ produits=:produits
    29/ management=:management
    30/ divers_eval=:divers_eval

    Les valeurs
    :
    1/ $candidat -> bindParam('nom', $_POST['nom']);
    2/ $candidat -> bindParam('prenom', $_POST['prenom']);
    3/ $candidat -> bindParam('adresse', $_POST['adresse']);
    4/ $candidat -> bindParam('departement', $_POST['dept'], PDO:ARAM_INT);
    5/ $candidat -> bindParam('email', $_POST['email']);
    6/ $candidat -> bindParam('tel', $_POST['tel'], PDO:ARAM_INT);
    7/ $candidat -> bindParam('date', date('Y,m,d'));
    8/ $candidat -> bindParam('sit_fam', $_POST['sit_fam']);
    9/ $candidat -> bindParam('age', $_POST['jour'], PDO:ARAM_INT);
    10/ $candidat -> bindParam('formation', $_POST['forma']);
    11/ $candidat -> bindParam('experience', $_POST['expe']);
    12/ $candidat -> bindParam('langue', $_POST['langue']);
    13/ $candidat -> bindParam('divers', $_POST['divers']);
    14/ $candidat -> bindParam('cv', $_POST['cv']);
    15/ $candidat -> bindParam('poste', $_POST['poste']);
    16/ $candidat -> bindParam('poste2', $_POST['poste2'], PDO:ARAM_INT);
    17/ $candidat -> bindParam('poste3', $_POST['poste3'], PDO:ARAM_INT);
    18/ $candidat -> bindParam('poste4', $_POST['poste4'], PDO:ARAM_INT);
    19/ $candidat -> bindParam('1departement', $_POST['dept'], PDO:ARAM_INT);
    20/ $candidat -> bindParam('1departement2', $_POST['dept2'], PDO:ARAM_INT);
    21/ $candidat -> bindParam('1departement3', $_POST['dept3'], PDO:ARAM_INT);
    22/ $candidat -> bindParam('1departement4', $_POST['dept4'], PDO:ARAM_INT);
    23/ $candidat -> bindParam('1region', $_POST['region'], PDO:ARAM_INT);
    24/ $candidat -> bindParam('id_user', $_SESSION['admin_id'], PDO:ARAM_INT);
    25/ $candidat -> bindParam('preavis', $_POST['preavis']);
    26/ $candidat -> bindParam('salaire', $_POST['salaire'], PDO:ARAM_INT);
    27/ $candidat -> bindParam('commentaire', $_POST['divers']);
    28/ $candidat -> bindParam('gestion', $_POST['gestion']);
    29/ $candidat -> bindParam('produits', $_POST['produits']);
    30/ $candidat -> bindParam('management', $_POST['management']);
    31/ $candidat -> bindParam('divers_eval', $_POST['com'], PDO:ARAM_INT);

    Si je ne me trompe pas, il y a 30 de renseignés, et 31 valeurs.
    Ce n'est pas concordant, alors il y a quelque chose qu'il faudra corriger (une de trop, ou une à rajouter, ça dépent).
    Hormis l'erreur de syntaxe à corriger aussi.

  9. #9
    Expert confirmé
    Avatar de rawsrc
    Homme Profil pro
    Dev indep
    Inscrit en
    Mars 2004
    Messages
    6 142
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 49
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Dev indep

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 142
    Billets dans le blog
    12
    Par défaut
    Citation Envoyé par RunCodePhp Voir le message
    Salut

    La syntaxe que tu utilise pour faire une insertion n'est pas bonne (sauf erreur).
    (c'est un mélange d'un INSERT et d'un UPDATE).

    La syntaxe c'est théoriquement comme ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    INSERT INTO nom_table (champ1, champ2, champN) VALUES (val1, val2, valN)
    Tu te trompes, la syntaxe qu'il utilise est prévue pour faciliter l'INSERT et l'UPDATE, regardes ici

Discussions similaires

  1. [MySQL] Erreur de requête
    Par Sebe dans le forum PHP & Base de données
    Réponses: 45
    Dernier message: 08/02/2006, 15h09
  2. [PHP MySQL] Erreur execution requête de type INSERT
    Par Pfeffer dans le forum Requêtes
    Réponses: 6
    Dernier message: 23/01/2006, 18h38
  3. [Debutant]Erreur Récurent - Requête
    Par ghan77 dans le forum Bases de données
    Réponses: 19
    Dernier message: 10/01/2006, 14h09
  4. erreur exécution requête
    Par MANU_2 dans le forum Bases de données
    Réponses: 4
    Dernier message: 13/10/2005, 08h27
  5. Erreur de requête :-(
    Par pekka77 dans le forum ASP
    Réponses: 2
    Dernier message: 28/06/2005, 14h53

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo