Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:\xampp\htdocs\search\action.php:7 Stack trace: #0 {main} thrown in C:\xampp\htdocs\search\action.php on line 7

I’m new to php . Please help me with this problem.

<?php  include 'config.php';

$output = ' ';
if (isset($_POST['query'])) {
  $search= $_POST['query'];
  $stmt=$conn->prepare("SELECT * FROM live_search WHERE first_name LIKE CONCAT('%'.?.'%') OR last_name LIKE CONCAT('%'.?.'%')");
  $stmt->bind_param("ss",$search,$search);
}
else {
  $stmt = $conn->prepare("SELECT * FROM live_search");
}
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows>0) {
  $output="<tr>
    <th>#</th>
    <th>first name</th>
    <th>last name</th>
    <th>email</th>
    <th>Gender</th>
  </tr>
  <tbody>";
  while ($row=$result->fetch_assoc()) {
    $output .= " <tr>
      <td> ". $row['id'] ." </td>
      <td> ". $row['first_name'] ." </td>
      <td> ". $row['last_name'] ." </td>
      <td> ". $row['email'] ." </td>
      <td> ". $row['gender'] ." </td>
    </tr> ";
  }
  $output .= "</tbody>";
  echo $output;
}

 ?>

Hello and welcome to the forum :grin:!

As stated on the documentation of PHP:

Which means your expected statement object is instead a boolean. You should check what the error says:

if (false === $stmt) {
  // Log the error and handle it:
  error_log('Could not create a statement:' . $conn->error);
}

Though the documentation references the procedural call, it applies to the OOP style too.