Fatal error: Uncaught TypeError: mysqli_fetch_object(): Argument #1 ($result) must be of type mysqli_result, bool given in C:\Users\dabya\OneDrive\Documents\xamp\htdocs\projectV2\Database.php:51 Stack trace: #0 C:\Users\dabya\OneDrive\Documents\xamp\htdocs\projectV2\Database.php(51): mysqli_fetch_object(false) #1 C:\Users\dabya\OneDrive\Documents\xamp\htdocs\projectV2\classes.php(873): Database->singleFetch(‘SELECT * FROM P…’) #2 C:\Users\dabya\OneDrive\Documents\xamp\htdocs\projectV2\manageSubject.php(7): Subjects->initWithSID(‘BU6001’) #3 {main} thrown in C:\Users\dabya\OneDrive\Documents\xamp\htdocs\projectV2\Database.php on line 51
function initWithSID($subjectID)
{
$db = Database::getInstance();
$data = $db->singleFetch('SELECT * FROM PLMS_subjects where subjectID = ' . $subjectID);
$this->initWith($data->subjectID, $data->subjectName, $data->MajorID, $data->CourseID);
}
<?php
include 'Header.php';
$subjectobject = new Subjects();
if (isset($_GET['subID']))
{
$sid= $_GET['subID'];
$subjectobject->initWithSID($sid);
$subID = $subjectobject->getSubjectID();
}