php - How to use multiple inner joins along with multiple WHERE clause in mysqli prepared starement? -


i trying write query want select clause based on first join condition , second clause based on second join. have written couple of ways, shows error:

fatal error: call member function bind_param() on boolean in /var/www/html/connections.php on line 80 

$user_id being fetched somewhere else. no issues that, if run single join here, works fine.

here query :

method 1 :

$sql = $db->prepare("select r.* registered_users r          inner join connections c2 on r.id = c2.uid         inner join connections c on r.id = c.connections_userid c2.connections_userid = ? or c.uid = ?");  $sql->bind_param("ii",$user_id,$user_id);            $sql->execute(); 

method 2 :

$sql = $db->prepare("select r.* registered_users r          inner join connections c2 on r.id = c2.uid     c2.connections_userid = ?         inner join connections c on r.id = c.connections_userid c.uid = ?");  $sql->bind_param("ii",$user_id,$user_id);            $sql->execute(); 

you have error prepare, check it

$sql = $db->prepare("select r.* registered_users r      inner join connections c2 on r.id = c2.uid     inner join connections c on r.id = c.connections_userid c2.connections_userid = ? or c.uid = ?");  if (!$sql) {    //error !! let's report it!    trigger_error($db->error); }  $sql->bind_param("ii",$user_id,$user_id);            $sql->execute();