I'm working on Codeigniter and I have a variable error. I am newly familiar with this framework and well the code is as follows:
Controller:
public function Todo(){
$new_id = $this->input->post('id');
$this->load->model('Model_app');
$data = $this->Model_app->GetNumeroActual($new_id);
if (!$data == null) {
$numero_actual_atencion = $data->numero_actual_atencion;
$this->load->model('Model_app');
$data = $this->Model_app->GetLetraServicio($new_id);
$identificador = $data->identificador;
$this->load->model('Model_app');
$data = $this->Model_app->GetModuloAtencionID($new_id,$numero_actual_atencion);
$moduloatencion_id = $data->moduloatencion_id;
$this->load->model('Model_app');
$data = $this->Model_app->GetNumeroModulo($moduloatencion_id);
$identificador2 = $data->identificador;
header('Content-Type: application/json');
echo json_encode(array($numero_actual_atencion,$identificador,$moduloatencion_id,$identificador2));
}
}
The case is that I enter an id and it returns a numero_actual_atencion
, I ask if the var $data
is different from null
and inside the if I take the numero_actual_atencion
and save it in a variable, then I send the same id to another query and I save what it returned in the var $identificador
, next act I send the same id and the numero_actual_atencion
obtained and I keep it in &moduloatencion_id
, I send the moduloatencion_id
and the return I keep it in the variable $identidicador2
and finally I apply
echo json_encode(array($numero_actual_atencion,$identificador,$moduloatencion_id,$identificador2));
to later be able to consume your data.
The error that throws me is the following:
A PHP Error was encountered
Severity: Notice
Message: Trying to get property of non-object
Filename: controllers / HernannMovil.php
Line Number: 27
Backtrace:
File: /Applications/XAMPP/xamppfiles/htdocs/wsatencion/application/controllers/HernannMovil.php Line: 27 Function: _error_handler
File: /Applications/XAMPP/xamppfiles/htdocs/wsatencion/index.php Line: 315 Function: require_once
Apparently the error is in this line:
$this->load->model('Model_app');
$data = $this->Model_app>GetModuloAtencionID($new_id,$numero_actual_atencion);
I think I'm not sending the var $numero_actual_atencion
causing it not to bring any data back.