Reputation: 5419
I am getting this warning when I try to run my code:
Creating default object from empty value (on line #24)
Controller:
public function createFields($tablename) {
$this->load->model(array('Connection_model', 'Read_data_model'));
$posts = $this->input->post(NULL, TRUE);
foreach ($posts as $key => $value) {
if (isset($value) && !empty($value) && isset($key) && !empty($key) && $key != 'submit') {
$this->Read_data_model->isset_row('sender', $tablename, $key);
}
}
}
Model:
public function isset_row($target, $table, $key) {
$this->load->model('Connection_model');
$query = $this->Connection_model->get_custom_db('sender')->get($table);
foreach ($query->result() as $row->{$key}) { // This is line #24
echo $row->{$key};
}
}
What am I doing wrong?
Upvotes: 1
Views: 147
Reputation: 5419
I found the solution myself. In the foreach loop it needs to be only $row
instead of $row->{$key}
.
Upvotes: 1