I am creating a webservice where I need to get some data from mysql and retrieve it in a mobile app.
I have been trying all day to do a query with a WHERE statement, but no success.
The normal query, without the WHERE is working perfectly though.
Also I went through all the similar questions on stack overflow and other forums, but none is the same problem as mine.
This is my current code:
<?php
$con=mysqli_connect("Hidden credentials");
if (mysqli_connect_errno())
{
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if ($stmt = $con->prepare("SELECT 
team.id as teamId,
team.team_name as teamName, 
user.id as userId, 
user.username as username, 
team_members.role as role
FROM team_members 
inner join user on team_members.user_id = user.id 
inner join team on team_members.team_id = team.id 
where user.id = ?
")) { 
   $stmt->bind_param("i", $id); 
   $stmt->execute(); 
   $result = $stmt->get_result();
$resultArray = array();
 $tempArray = array();
 while($row = $result->fetch_object())
 {
    $tempArray = $row;
    array_push($resultArray, $tempArray);
 }
 echo json_encode($resultArray);
 $stmt->close();
}
?>
If I remove the line where user.id=? it gets the data correctly. 
Running the query on phpMyAdmin is everything ok, so it's not any issue on the query.
 
     
    