I have tried to make a stored procedure like this:
DELIMITER $$
DROP PROCEDURE IF EXISTS get_userStatUser $$
CREATE PROCEDURE get_UserStatUser
(
IN userId INT,
OUT Played INT,
OUT Win INT,
OUT Points INT
)
BEGIN
SELECT played, win, points
INTO Played, Win, Points
FROM nf_users
WHERE id = userId;
END $$
DELIMITER ;
I then try to get data from it like this:
$sql = mysqli_query($connect,"CALL get_userStatUser()") or die("Query fail: " . mysqli_error());
$row = mysqli_fetch_array($sql);
$played = $row['Played'];
$win = $row['Win'];
$points = $row['Points'];
But something is not right. I’m new to Stored Procedures and can not see where I go wrong? I get “Query fail:” with nothing in the error?
Any help is apreciated and thanks in advance 🙂
The Stored Procedure needs 4 parameters
Given the way your PHP calls the Stored Procedure, you need to redefine the following:
your PHP
Give it a Try !!!