Question: I'm trying to insert demo records from some simple form using active records and codeigniter

```
function create_httpPost()
{
   $data = array(
      'title' => $this->input->post('title'),
      'content' => $this->input->post('content')
   );

   $this->newsModel->createData($data); //error occures here
   $this->index();//aka redirectToAction
}

```

but after posting form I'm getting following error

> 
> \*\*Message: Undefined property: News::$newsModel
> 
> 
> Filename: controllers/news.php Line Number: 29\*\*
> 
> 
> 

Inside model I have this method

```
function createData($data)
    {
        $this->db->insert('News', $data);
        return;
    }

```

what I'm doing wrong here?

Answer: 
Try this:

```
function create_httpPost()
{
   $this->load->model('newsModel'); // you need to load model

   $this->newsModel->createData(array(
      'title'   => $this->input->post('title', TRUE),
      'content' => $this->input->post('content', TRUE)
   ));

   $this->index();
}

```
This is very comman problem with CI2.

this function must be inside one of ur models right ?

if so, please note that `u can't reference model from inside other model` ! for some reason. u need to let controller handle that