Pdostatement::execute() error: SQLSTATE[HY093]: Invalid Parameter number

Asked

Viewed 4,960 times

1

I have the following code, I used another similar to do a database update, but this now does not work; it gives the following error:

Warning: Pdostatement::execute(): SQLSTATE[HY093]: Invalid number: Parameter was not defined in C: wamp www F1 php_programmes modificateurpilote.php on line 17

<?php
$dbh = new PDO('mysql:host=localhost;dbname=tc4','root','');
$dbh->query('SET NAMES utf8');
$prendre = $dbh->prepare('UPDATE pilotes SET Nom=:mNom, Nationalite= :mNationalite,DateDeNaissance= :mDateDeNaissance, Annees= :mAnnees, Equipe= :mEquipe, NombreDeGP= :mNombreDeGP, Podiums= :mPodiums, Victoires= :mVictoires, TitresPilote= :TitresPilote, Description= :mDescription WHERE Id='.$_POST['id']);
$prendre->execute(array('mNom'=> $_POST['Nom'],
    'mNationalite'=> $_POST['Nationalite'],
    'mDateDeNaissance'=> $_POST['DateDeNaissance'],
    'mAnnees'=> $_POST['Annees'],
    'mEquipe'=> $_POST['Equipe'],
    'mNombreDeGP'=> $_POST['NombreDeGP'],
    'mPodiums'=> $_POST['Podiums'],
    'mVictoires'=> $_POST['Victoires'],
    'mTitresPilote'=> $_POST['TitresPilote'],
    'mDescription'=> $_POST['Description']
    )
);

?>

  • What’s on line 17 of the file modificateurpilote.php?

  • 1

    Line 17, was the end of the job already...

  • opaaaa, friend, I found the solution, just below

  • 1

    Oops, I saw it. Cool. :D

1 answer

2

I discovered the mistake, it was that I forgot to put the variable of modification the m there to differentiate, in:

TitresPilote= :TitresPilote

Which in this case should be:

TitresPilote= :mTitresPilote

Then the error occurred because it did not have this parameter defined.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.