Click here to Skip to main content
15,887,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Je reçois cette erreur:
Une erreur PHP a été rencontrée
Severity: Avertissement
Message: Undefined array key "id"
Nom du fichier: controllers/patient.php
Numéro de la ligne: 353

voici le code:

PHP
  1   if (empty($id)) {     // Adding New Patient
  2                  if ($this->ion_auth->email_check($email)) {
  3                      $this->session->set_flashdata('feedback', 'Cette adresse email est déjà enregistré dans la base données');
  4                      redirect('patient/addNewView');
  5                  } else {
  6                      $dfg = 5;
  7                      $this->ion_auth->register($username, $password, $email, $dfg);
  8  //                    $ion_user_id=this->db-get_where('users', array('email'=> $email))->row()['id'];
  9                      $ion_user_id = $this->db->get_where('users', array('email' => $email))->row()['id'];
 10                      $this->patient_model->insertPatient($data);
 11                      $patient_user_id = $this->db->get_where('patient', array('email' => $email))->row()->id;
 12                      $id_info = array('ion_user_id' => $ion_user_id);
 13                      $this->patient_model->updatePatient($patient_user_id, $id_info);
 14                      $this->hospital_model->addHospitalIdToIonUser($ion_user_id, $this->hospital_id);
 15  
 16                      if (!empty($sms)) {
 17                          $this->sms->sendSmsDuringPatientRegistration($patient_user_id);
 18                      }
 19  
 20  
 21                      $this->session->set_flashdata('feedback', 'Ajouté');
 22                  }
 23                  //    }
 24              } else { // Updating Patient
 25                  $ion_user_id = $this->db->get_where('patient', array('id' => $id))->row()->ion_user_id;
 26                  if (empty($password)) {
 27                      $password = $this->db->get_where('users', array('id' => $ion_user_id))->row()->password;
 28                  } else {
 29                      $password = $this->ion_auth_model->hash_password($password);
 30                  }
 31                  $this->patient_model->updateIonUser($username, $email, $password, $ion_user_id);
 32                  $this->patient_model->updatePatient($id, $data);
 33                  $this->session->set_flashdata('feedback', 'Modifié');
 34              }
 35              // Loading View
 36              if (!empty($redirect)) {
 37                  redirect('finance/addPaymentView');
 38              } else {
 39                  redirect('patient');
 40              }
 41          }
 42      }



Translation:
How can I resolve this error on

I'm getting this error:
A PHP error has been encountered
Severity: Warning
Message: Undefined array key "id"
File name: controllers/patient.php
Line Number: 353

What I have tried:

Cette erreur apparait lorsque j'essaie d'enregistrer un nouveau patient

Translation:
This error appears when I try to register a new patient
Posted
Updated 17-Dec-23 4:10am
v4
Comments
Richard MacCutchan 16-Dec-23 11:58am    
Which one out of those 42 lines is line number 353? Also, please note this is an English language forum, please translate your message(s) before posting.
0x01AA 17-Dec-23 10:11am    
I added Line Numbers for the code. Looks like you did not post the code in question...

1 solution

Your error is most probably at this line -
PHP
$ion_user_id = $this->db->get_where('users', array('email' => $email))->row()['id'];


It refers to the name you are using 'id', which is undefined, meaning that the name does not exist in your array.

In order for us to give you a better answer, show us the correct naming of 'id', is it maybe 'Id' or 'ID' etc. Also show us what your array names are, but the above should suffice to fix your problem.

You can read more on arrays and it's usage at - PHP array_keys | Tutorial[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900