Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens and i am new ussin pdo for connection to database

    $query="INSERT INTO users (username,pwd,email) values(':userName',':pwd',':Email')";
    $stmt=$pdo->prepare($query);

    $stmt->bindParam(':userName',$username);
    $stmt->bindParam(':pwd',$password);
    $stmt->bindParam(':Email',$email);

    $stmt->execute();

here’s my code my parameter are same but it keeps giving me this error

i have tried changing the placeholders names but did not work

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

In your query you have quotes around the placeholder names, making them into strings.

If you remove them it should, hopefully, work.

Like this:

$query="INSERT INTO users (username,pwd,email) values(:userName,:pwd,:Email)";
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading