Good afternoon,
I have this code that is supposed to give me the number of books in the database, but it does not work.
public function getTotalBooks() {
$sql = $this->db->prepare("SELECT * FROM libros");
$result = $sql->execute();
$rows = $result->num_rows();
echo $rows;
}
I get this error:
Fatal error: Uncaught Error: Call to a member function num_rows() on boolean in C:\xampp\htdocs\CBSLibrary\assets\private\classes\class.statics.php:17 Stack trace: #0 C:\xampp\htdocs\CBSLibrary\administration\settings\library.php(265): Statics->getTotalBooks() #1 {main} thrown in C:\xampp\htdocs\CBSLibrary\assets\private\classes\class.statics.php on line 17
I have tried to do it in a thousand ways after 1 hour searching the internet for the error, but I have not found one that works.