I've been struggline with this for a while now. I am simply not able to return a single value. I can return arrays just fine. But not a single value. I have a database with just three columns, column1 is userID, column2 is friendID and column3 is IfFriends, which has the value 0 or 1.
Now if I make the following function:
function CheckFriend($id, $friendid){
global $mysqli;
$stmt = $mysqli->prepare("SELECT IfFriends FROM friends WHERE userID=?
AND friendID=?");
$stmt->bind_param("ii", $id, $friendid);
$stmt->bind_result($IfFriends);
$stmt->execute();
return $IfFriends;
Now am I doing it wrong? I tried the SQL query and it works, it gives me back the 1. However if I use the function it gives me back 0.
In PHP I have it written like this:
$iffriends = CheckFriend($_SESSION["id"], $_REQUEST["friendid"]);
And when I do:
echo $iffriends
It always gives me back a 0, no matter what.
I hope someone is able to take the time and tell me what I am doing wrong. Thank you in advance.