0

ErrorException (E_NOTICE) Trying to get property of non-object. Old items deleted succesfully this issue occurs in new added items.

public function getItemPreviewToDelete($id)
    {
        $this->db->where('pre_item_id', $id);
        $query = $this->db->get('zd_item_previews');
        return $query->row(2)->pre_name;
    }

  • 1
    Are you sure that you always have a value in $query->row(2)->pre_name? why row(2)? – Hardood May 28 '20 at 09:13
  • Do a var_dump of $query and look what's inside it (and what $query->row really is, if it exists at all) – Max May 28 '20 at 16:42

1 Answers1

0

Try checking if you are getting pre_name or not by adding below code

print "<pre>";
print_r($query->result_array());
print "</pre>";

Before this line

return $query->row(2)->pre_name;
krr2020
  • 23
  • 1
  • 7