Click here to Skip to main content
15,888,610 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
Chrome

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';
exit;
}

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

$stmt->bind_result($a,$b,$c,$d);


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:
$stmt->bind_param('s',$searchterm);


Thanks for feedback about the code.
JurajB

What I have tried:

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

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.
PHP
$stmt = $db->prepare($query);
 
Share this answer
 
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
 

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