Hi all,
I have a question regarding accessing a MySQL stored procedure from PHP. Basically, I cannot figure out how to access an OUT parameter returned from a MySQL stored procedure.
My MySQL procedure “login” takes a username and password as IN parameters, and outputs a userID through an OUT parameter. I am, however, unable to access the returned userID parameter in PHP.
MySQL stored procedure:
CREATE PROCEDURE login (IN inputUsername VARCHAR(50), IN inputPassword VARCHAR(255), OUT result INT UNSIGNED)
SQL SECURITY DEFINER
BEGIN
SET result = 0;
SELECT userID INTO result FROM Users WHERE username = inputUsername AND password = SHA1(inputPassword);
END
//
How do I access the userID OUT parameter in PHP?
$query = “CALL login(‘”.username.”’, ‘”.password.”’, ???)”;
I am using MySQL 5.0.2, PHP 5.0.3, the mysqli module and apache 2.0.53.
I’ve been searching the web and MySQL / PHP manuals but can not find any answers. Any help would be greatly appreciated.
Thanks in advance.
Chris