Reputation: 83
I have the following code:
$selectUserQuery = 'SELECT email_address, password FROM user WHERE email_address = :email_address AND password = :password';
$prepSelectUser = $conn->prepare($selectUserQuery);
/*
* HOW DO I ADD MULTIPLE PARAMETERS TO THIS BINDPARAM() FUNCTION?
*/
$prepSelectUser->bindParam(':email_address', $email, PDO::PARAM_INT);
$prepSelectUser->execute();
$userResult = $prepSelectUser->fetchAll();
$userCount = count($userResult);
How can I add multiple parameters to the bindParam() function?
Upvotes: 0
Views: 6082
Reputation: 157839
You don't actually need this function at all. as well as most of other code you used.
$sql = 'SELECT 1 FROM user WHERE email_address = ? AND password = ?';
$stmt = $conn->prepare($sql);
$stmt->execute([$email, $password]);
$userCount = $stmt->fetchColumn();
Upvotes: 6
Reputation: 6120
First, change
$prepSelectUser->bindParam(':email_address', $email, PDO::PARAM_INT);
to
$prepSelectUser->bindParam(':email_address', $email, PDO::PARAM_STR);
then call another bindParam, like
$prepSelectUser->bindParam(':password', $password, PDO::PARAM_STR);
Upvotes: 1