0

I am working on a small project for a social network. My issue is while using multiple inner joins bind_param throws up an error

Fatal error: Call to a member function bind_param() on boolean in /var/www/html/index.php on line <line number>

Here is my code :

$user_id is already being fetched from somewhere else, no issues with that. Also, if I only use a single inner join here, it works.

index.php

$sqlFetchUserList = $db->prepare("SELECT r.* from registered_users r inner join connections c
        on r.id = c.connections_userid 
        inner join connections c 
        on r.id = c.uid 
        where c.uid = ? or c.connections_userid = ?");  
       $sqlFetchUserList->bind_param("ii",$user_id,$user_id);
       $sqlFetchUserList->execute();
       $sqlFetchUserList = $sqlFetchUserList->get_result();

I am trying to select all the data to and fro wherever there is a corresponding record in the columns.

I know I am doing something wrong here but not able to figure it out so far.

1 Answers1

0

The mysqli_prepare function returns FALSE when there's an error.

Return Values

mysqli_prepare() returns a statement object or FALSE if an error occurred.

http://php.net/manual/en/mysqli.prepare.php

You want to check the return from the prepare. If it's FALSE (a boolean) it's not a valid statement handle. So handle the error. You can call mysqli_error() to find out what the MySQL error is.

For debugging, take the SQL text to a different MySQL client and test it, to find out where the problem is and how to fix it.

Community
  • 1
  • 1
spencer7593
  • 103,596
  • 14
  • 107
  • 133