The following is my MySQL stored procedure:
DROP PROCEDURE IF EXISTS sp_authenticate;
CREATE PROCEDURE sp_authenticate(IN user_name VARCHAR(50),
IN password1 VARCHAR(50), OUT nmatch INT)
BEGIN
SELECT COUNT(*) INTO nmatch
FROM user1 u
WHERE u.name = user_name AND
u.password1 = password1;
END//
This is how I am calling it from PHP:
function authenticate($pdo, $user_name, $password){
$stmt = $pdo->prepare('CALL sp_authenticate(:user_name, :password, :nmatch)');
$stmt->bindValue(':user_name', $user_name, PDO::PARAM_STR);
$stmt->bindValue(':password', $password, PDO::PARAM_STR);
$nmatch = 888888;
$stmt->bindParam(':nmatch', $nmatch, PDO::PARAM_INT, 4);
$result = $stmt->execute();
return $nmatch;
}
$nmatch always retains it's old value and does not receive the value from the stored procedure. What could I be doing wrong here?
MySQL Server Version: 5.5.22 PHP Version: 5.3.10