This topic is locked

Error when Check other table before Import Data (Before Import Started)

7/29/2021 7:44:05 PM
PHPRunner General questions
J
jackwood author

I've got Error message:
Fatal error: Uncaught Error: Call to a member function fetchAssoc() on bool in D:\xampp\htdocs\payroll\include\import_data_lembur_events.php:144 Stack trace: #0 D:\xampp\htdocs\payroll\classes\importpage.php(172): eventclass_import_data_lembur->BeforeImport(Object(ImportPage), '') #1 D:\xampp\htdocs\payroll\classes\importpage.php(91): ImportPage->runImportAndSendResultReport() #2 D:\xampp\htdocs\payroll\import_data_lembur_import.php(49): ImportPage->process() #3 {main} thrown in D:\xampp\htdocs\payroll\include\import_data_lembur_events.php on line 144

What wrong with this Query ?

$rs = DB::Query("select count(id) as c from attendance where employee_id = " . $values["employee_id"] . " and date = '" . $values["overtimedate"] . "'");
$data = $rs->fetchAssoc();
$count = $data["c"];
if ($count >=1)
{
$values['company']= $_SESSION["company"];
$values['import_by']= $_SESSION["userid"];
$values["import_date"]=now();
return true;
}
else
{
$message = "Sorry, Your Import Data will not be imported because the attendance Data Still Empty";
exit();
}

admin 7/29/2021

Most likely your query doesn't return any records and this why you are getting this error.