1

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?

1
  • use StdClass for empty object Commented Apr 5, 2015 at 0:15

1 Answer 1

1

I found the solution myself. In the foreach loop it needs to be only $row instead of $row->{$key}.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.