how to get mysql function return value in variable using php
Posted: Sun Jun 26, 2016 12:31 am
Delimiter $
CREATE FUNCTION FP_USER_EXISTS(xemailid VARCHAR(50)) RETURNS int(11)
BEGIN
SET @User_exists = 0;
SELECT COUNT(*) INTO @found FROM login WHERE emailid = xemailid;
IF @found > 0 THEN
SET @User_exists = 1;
END IF;
RETURN @User_exists;
END $$
function calling in mysql
@return=FP_USER_EXISTS('testing@test.com')
select @return here it shows return value 0 or 1 but in php it is not returing value
$ret=mysqli_query($connection,"select FP_USER_EXISTS('$emailid')");
if($ret==1)
{
echo "User already exits";
}
else
{
echo 'Inserted successfully';
}
every time it is showing one value based on condition
Thanks
CREATE FUNCTION FP_USER_EXISTS(xemailid VARCHAR(50)) RETURNS int(11)
BEGIN
SET @User_exists = 0;
SELECT COUNT(*) INTO @found FROM login WHERE emailid = xemailid;
IF @found > 0 THEN
SET @User_exists = 1;
END IF;
RETURN @User_exists;
END $$
function calling in mysql
@return=FP_USER_EXISTS('testing@test.com')
select @return here it shows return value 0 or 1 but in php it is not returing value
$ret=mysqli_query($connection,"select FP_USER_EXISTS('$emailid')");
if($ret==1)
{
echo "User already exits";
}
else
{
echo 'Inserted successfully';
}
every time it is showing one value based on condition
Thanks