我找不到这个代码失败的地方
$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'
但如果我改为
$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));
它工作正常 请帮我找出问题所在。
答案 0 :(得分:0)
当您使用:UsedID
绑定参数时,查询中的占位符正在查找:UserID