I have this Stored Procedure. When I execute it in my PhpMyAdmin on Wamp, it says it executed and everything. When I try to use it in a query, it says the function is not there. What am I doing wrong?
DELIMITER //
CREATE PROCEDURE `sql_level`(IN exp INT)
BEGIN
SELECT id
FROM `levels`
WHERE experience <= exp DESC LIMIT 1;
id = id-1;
END //
DELIMITER ;
Here is the Query I’m trying to run.
$id = 1;
if($stmt->prepare("SELECT sql_level(attack) FROM `users` WHERE id = ?")) {
$stmt->bind_param('i',$id);
$stmt->execute();
$stmt->bind_result($attack);
$stmt->fetch(); echo "<h1 align='center'>".$attack."</h1>"; }
else { die($stmt->error); }
Thanks.
This is what I ended up using to make it work. Thanks! Hope this helps someone!