I’m getting this error:
Attempt to read property"id" on array
File name: controler/patient.php
Line 352
I had just modified by putting the entire code for further clarification
This is the code:
$username = $this->input->post('name');
if (empty($id)) { // Adding New Patient
if ($this->ion_auth->email_check($email)) {
$this->session->set_flashdata('feedback', 'Cette adresse email est déjà enregistré dans la base données');
redirect('patient/addNewView');
} else {
$dfg = 5;
$this->ion_auth->register($username, $password, $email, $dfg);
// $ion_user_id=this->db-get_where('users', array('email'=> $email))->row()['id'];
// $ion_user_id = $this->db->get_where('users', array('email' => $email))->row()['id'];
$ion_user_id = $this->db->get_where('users', array('email' => $email))->row()->id;
if ($ion_user_id) {
$ion_user_id = $ion_user_id->row()->id;
}
$this->patient_model->insertPatient($data);
$patient_user_id = $this->db->get_where('pa;tient', array('email' => $email))->row()->id;
$id_info = array('ion_user_id' => $ion_user_id);
$this->patient_model->updatePatient($patient_user_id, $id_info);
$this->hospital_model->addHospitalIdToIonUser($ion_user_id, $this->hospital_id);
if (!empty($sms)) {
$this->sms->sendSmsDuringPatientRegistration($patient_user_id);
}
$this->session->set_flashdata('feedback', 'Ajouté');
}
// }
} else { // Updating Patient
$ion_user_id = $this->db->get_where('patient', array('id' => $id))->row()->ion_user_id;
if (empty($password)) {
$password = $this->db->get_where('users', array('id' => $ion_user_id))->row()->password;
} else {
$password = $this->ion_auth_model->hash_password($password);
}
$this->patient_model->updateIonUser($username, $email, $password, $ion_user_id);
$this->patient_model->updatePatient($id, $data);
$this->session->set_flashdata('feedback', 'Modifié');
}
// Loading View
if (!empty($redirect)) {
redirect('finance/addPaymentView');
} else {
redirect('patient');
}
}
}
I want to know how can I solve that
2
Answers
if you are facing the issue on the following line :
than firstly confirm that you are getting "row()" as not empty and hence after validating this one as not empty than check you are getting "row()" as "stdObject", if it’s stdObject than it’s fine if it’s not object than try as
plz mention the full code with error so that anyone can understand the problem and can answer
as of my knowledge what are you want to access in first line of your code is id is constant if not then it will be mostly variable if variable then use $id
so first modify the first line of code from
to
if you are facing error in last line
then first check $ion_user_id like this because if you don’t get any result then it return false