Created a mysql stored procedure and have accessed from php output parameter returns an integer value .cant get it at php code .any experts help to solve this would be appreciated . When i execute in he Mysql admin its returning 30 when i execute from php the session varibale return nothing ..
SQL CODE
CREATE PROCEDURE `Gettotdownlines`(
IN `useridmobile` VARCHAR(20),
OUT `totlevelcount` INT(6)
)
BEGIN
select count(*) INTO totlevelcount from templeveltable;
END
try {
$sql = 'CALL Gettotdownlines(:useridmobile,@levelcount)';
$stmt = $conn->prepare($sql);
$stmt->bindParam(':useridmobile', $shopidd, PDO::PARAM_STR);
$stmt->execute();
$stmt->closeCursor();
$row = $conn->query("SELECT @totlevelcount as ss")->fetch();
if ($row) {
if(count($row)>0)
{
$_SESSION['totaldownlines']=$row['ss'];
}
else
{
$_SESSION['totaldownlines'] =0;
}
}
} catch (PDOException $e) {
die("Error occurred:" . $e->getMessage());
}
It is probably because you are fetching a wrong variable "SELECT @totlevelcount as ss" change it to "SELECT @levelcount as ss"