its my first time creating a php OOP website. i have encountered this error and have tried to understand it from other people who had similar errors but i cant find a perfect solution. This is what is being outputed.
Fatal error: Uncaught Error: Call to a member function fetch_assoc() on bool in D:\Xampp\htdocs\online_exam\classes\Exam.php:88 Stack trace: #0 D:\Xampp\htdocs\online_exam\test.php(12): Exam->getQuesByNumber(5) #1 {main} thrown in D:\Xampp\htdocs\online_exam\classes\Exam.php on line 88
And these are codes it directs to.
(test.php)
<?php
Session::checkSession();
if(isset($_GET['q'])){
$number = (int)$_GET['q']; /*here now $number = quesNo*/
}else{
header("Location:exam.php");
}
$total=$exm->getTotalRows();
$question=$exm->getQuesByNumber($number);
?>
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$process = $pro->processData($_POST);
}
?>
Exam.php for functions
public function getQuesByNumber($number){
$query = "SELECT * FROM tbl_ques WHERE quesNo = '$number'";
$getDataRow = $this->db->select($query);
$result = $getDataRow->fetch_assoc();
return $result;
}
from my research i've seen most people say that mysql string may be wrong but it seems not the case as i have crosschecked thoroughly for hours yet still the same outcome no matter what i do.
Any help, suggestions or opinions will be very helpful.