0

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

and this is the code:

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
        }           }
IKavanagh
  • 6,089
  • 11
  • 42
  • 47
Hony Jamal
  • 11
  • 1
  • 3
  • 1
    Possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Sherif Oct 25 '15 at 09:56

1 Answers1

1

Assuming line 749 of the file C:\AppServ\www\hfix\include\care_api_classes\class_mini_dental.php is referring to this line in your example...

    if($this->row=$this->result->FetchRow()){

Then your problem is that $this->result is not an object. You assign $this->result on the previous line with the return value of $db->Execute($this->sql). So if $db->Execute() returns anything other than object you would get that error. My guess is $db->Execute() failed to execute your query for one reason or another and return a boolean false or some other non-object value as indication of failure. You should check the return value for errors first before blindly using it like this.

Also see https://stackoverflow.com/a/12769983/1878262 [related]

Community
  • 1
  • 1
Sherif
  • 11,786
  • 3
  • 32
  • 57