title: creating news item in codeigniter
body: <p>i want to create news item in codeigniter with use slug but is error display like this.</p>
  
  <pre><code>&gt; Call to a member function insert() on a non-object in line 34
  </code></pre>
  
  <p>I am a newbie in Codeigniter and couldn't really figure out how to solve this.</p>
  
  <p>my controller</p>
  
  <pre><code>    function tambah_profil()
          {
              $this-&gt;data['title'] ='create a new items';
  
              $this-&gt;form_validation-&gt;set_rules('judul', 'Judul', 'required');
              $this-&gt;form_validation-&gt;set_rules('content', 'Content', 'required');
  
              if ($this-&gt;form_validation-&gt;run() == FALSE) 
              {
                  $this-&gt;data['contents'] = $this-&gt;load-&gt;view('admin/profil/tambah_profil', '', true);
  
              }else{
  
                  $this-&gt;mhalaman-&gt;insert_profil();
                  $this-&gt;data['contents'] = $this-&gt;load-&gt;view('admin/profil/view_profil', '', true);
  
              }
  
              $this-&gt;data['orang'] = $this-&gt;mlogin-&gt;dataPengguna($this-&gt;session-&gt;userdata('username'));
              $this-&gt;data['contents'] = $this-&gt;load-&gt;view('admin/profil/tambah_profil', '', true);
              //$this-&gt;data['contents'] = 'admin/profil/tambah_profil';
              $this-&gt;load-&gt;view('template/wrapper/admin/wrapper_ukm',$this-&gt;data);
          }
  </code></pre>
  
  <p>my model</p>
  
  <pre><code>var $db;
      private $tbl_halaman = 'halaman';
  
      public function __construct()
      {
          parent ::__construct();
          $this-&gt;load-&gt;database();
      }
  
      function get_profil($slug = FALSE)
      {
          if ($slug === FALSE)
          {
              $query = $this-&gt;db-&gt;get($this-&gt;tbl_halaman);
              return $query-&gt;result_array();
          }
  
          $query = $this-&gt;db-&gt;get_where($this-&gt;tbl_halaman, array('slug'=&gt;$slug));
          return $query-&gt;row_array();
      }
  function insert_profil()
          {
              $slug = url_title($this-&gt;input-&gt;post('judul'),'dash', TRUE);
  
              $data = array(
                  'judul'         =&gt; $this-&gt;input-&gt;post('judul'),
                  'slug'          =&gt; $slug,
                  'content'       =&gt; $this-&gt;input-&gt;post('content')
              );
              return $this-&gt;db-&gt;insert($this-&gt;tbl_halaman ,$data); //line 34
          }
  </code></pre>
  
  <p>please help me what to do. thank you.</p>