1
我面臨着以下錯誤:錯誤試圖讓非對象和未定義變量的性質:笨
Trying to get property of non-object and Undefined variable php errors in my code
控制器:
function showDoctorInformation(){
$this->load->model('PatientModel');
$data['doctorinfo'] = $this->PatientModel->getDoctorInformation();
$this->parser->parse('patient_msgview', $data);
}
型號:
function getDoctorId() {
$this->db->from('person');
$this->db->select('doctorId');
$doctorId = $this->db->get()->result();
return $doctorId;
}
function getDoctorInformation() {
$doctorId = $this->getDoctorId();
$this->db->from('DoctorInfo');
$this->db->where('doctorId', $doctorId);
$this->db->select('name', 'surname', 'Bio', 'Address', 'img');
$doctorinfo = $this->db->get()->result();
return $doctorinfo;
}
查看:
<?= $doctorinfo->name ?>
我已經使用此方法顯示數據庫中的信息,但現在看不到錯誤。
函數getDoctorId在函數getDoctorInformation中被調用,我試過但仍然是相同的錯誤。 –
使用我的更新後的代碼?也波西完整的錯誤消息 – Saty
是使用後,更新後的我得到這個錯誤: 一個PHP錯誤遇到 嚴重性:注意 消息:未定義的變量:doctorinfo 文件名:觀點/ patient_msgview.php 行號:100 回溯: 文件:/home/a15_web01/web/application/views/patient_msgview.php 線:100 功能:_error_handler 文件:/首頁/ a15_web01 /網絡/ applicati上/控制器/ PatientController.php 線:51 功能:解析 文件:/home/a15_web01/web/index.php 線:292 功能:require_once –