This question already has an answer here:
This is my error message Fatal error: Call to a member function FetchRow() on a non-object in C:\AppServ\www\hfix\include\care_api_classes\class_mini_dental.php on line 749
while ($loly<$numdays){
$income = 0;
$cost = 0;
$costs = 0;
$dt = $yrs . '-' . $mnth . '-' . $loly;
if ($cc=='0'){$cc='1';} else{$cc='0';}
$this->sql='SELECT `encounter_nr`,`article_item_number`,`dosage`,`price` FROM `care_encounter_prescription` WHERE `bill_status` = "archived" AND `prescribe_date` = "'.$dt.'" ORDER BY encounter_nr ASC ';
$this->result=$db->Execute($this->sql);
$this->sql='SELECT DISTINCT(`encounter_nr`) FROM `care_encounter_prescription` WHERE `bill_status` = "archived" AND `prescribe_date` = "'.$dt.'" ORDER BY encounter_nr ASC ';
$this->newquery=$db->Execute($this->sql);
$patients = $this->newquery->RecordCount();
while($this->zrow = $this->result->FetchRow()){
$this->sql = 'SELECT `unit_cost` FROM `care_tz_drugsandservices` WHERE `item_id` = '.$this->row[1];
$this->lastquery=$db->Execute($this->sql);
if ($vx = $this->lastquery->FetchRow()) $cost = $vx[0];
else $cost = 0;
$costs += $this->row[2] * $cost; # dosage * cost
$income += $this->row[2] * $this->row[3]; # dosage * price
}
</div>
This query:
$this->sql = 'SELECT `unit_cost` FROM `care_tz_drugsandservices` WHERE `item_id` = '.$this->row[1];
Doesn't return any rows. You can confirm this by testing it in phpMyAdmin. FetchRow doesn't handle these exceptions gracefully, so you will need to test the result of the query before starting to fetch rows.