Click here to Skip to main content
15,559,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, Im starting PHP programming, learning from the book but the code dont work.
XAMPP 8.0.x
Windows 11

Dont know if its outdated or what to do.
Posted more of code for resolution.
Here it is:
@$db = new mysqli('localhost', 'bookorama', 'bookorama123', 'books');
if (mysqli_connect_errorno()) {
echo 'typing an error msg';

$query = "SELECT ...
WHERE $searchtype LIKE ?"
$stmt = $db->prepare($query);
$searchterm = '%'.$searchterm.'%';


The problem is:
Fatal error: Uncaught Error: Call to a member function bind_param() on bool in D:\xampp\htdocs\results.php:40 Stack trace: #0 {main} thrown in D:\xampp\htdocs\results.php on line 40

here is line 40:

Thanks for feedback about the code.

What I have tried:

I dont know if the problem is with object oriented programming or what.
Updated 9-Nov-21 1:16am

Call to a member function bind_param() on bool

$stmt variable contains a boolean value, most probably false, indicating that the preparation of the query did not go so well.

You should double-check your query and make sure it is correct.
Share this answer
The error message is telling you that $stmt is not a valid statement object. This is caused by the following statement failing; most likely because your SELECT is incorrect.
$stmt = $db->prepare($query);
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900