我有以下連接這是工作正常,但我想包括從表中一個新的變量用戶ID列:連接與PDO使用綁定值不工作
public function userLogin()
{
$success = false;
try {
$con = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM users WHERE username = :username AND password = :password LIMIT 1";
$stmt = $con->prepare($sql);
$stmt->bindValue("username", $this->username, PDO::PARAM_STR);
$stmt->bindValue("password", hash("sha256", $this->password . $this->salt), PDO::PARAM_STR);
$stmt->bindValue("UserID", $this->userID, PDO::PARAM_STR);
$stmt->execute();
$valid = $stmt->fetchColumn();
if($valid) {
$success = true;
}
$con = null;
return $success;
當我加入我的新線$stmt->bindValue("UserID", $this->userID, PDO::PARAM_STR);
它說錯誤:SQLSTATE [HY093]:無效的參數編號:綁定變量的數量不符令牌
的數,其中可能有問題?
ü綁定3個值,而僅使用兩個.. –