我有以下工作正常的连接,但我想将表中的 userID 列包含在新变量中:
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]:无效的参数号:绑定变量的数量与令牌的数量不匹配
问题可能出在哪里?