0

I can not found where is my fail with this code

 $username = $_POST["UserID"];
 $password = $_POST["PWD"];
 $sql = 'select COUNT(*) from Staff where UserID = :UserID and PWD = :PWD';
 $result = $cnnEmployee->prepare($sql);
 $result->bindParam(':UsedID',$username, PDO::PARAM_STR)
 $result->bindParam(':PWD',$password, PDO::PARAM_STR)
 $result->execute(); //Error here: Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: parameter was not defined'

But if I change to

 $username = $_POST["UserID"];
 $password = $_POST["PWD"];
 $sql = 'select COUNT(*) from Staff where UserID = :UserID and PWD = :PWD';
 $result = $cnnEmployee->prepare($sql);
 $result->execute(array(':UserID'=>$username, ':PWD'=>$password));

it work fine Pls help me to find where is my problem.

BCKien
  • 1

1 Answers1

0

When you're binding the parameters you use :UsedID but the placeholder in the query is looking for :UserID

xcvd
  • 666
  • 1
  • 5
  • 13