Answer the question
In order to leave comments, you need to log in
How to fix Call to a member function result() on a non-object in?
Good day.
I am using codeigniter framework in php. This is the situation:
In the controller:
$data_app = array(
'key_api' => substr(md5(uniqid(rand(), true)), 0, 22)
);
$data['app'] = $data_app;
$this->load->view('apps/new', $data);
<?php foreach ($app->result() as $data): ?>
<?= $data->key_api; ?>
<?php endforeach; ?>
Answer the question
In order to leave comments, you need to log in
$app is an array, not an object! where does it get the result() method from?
This is exactly what the error tells you that you are trying to call the result () method from a non-object.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question