CodeIgniter Forums
Help for begginier... Can't figure out problem. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Help for begginier... Can't figure out problem. (/showthread.php?tid=52173)



Help for begginier... Can't figure out problem. - El Forum - 05-31-2012

[eluser]dkindler[/eluser]
Hi. Everytime I run my website, I get the following error:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Submit::$post_model

Filename: controllers/submit.php

Line Number: 9

I can't figure out what I'm doing wrong... I've been trying to figure it out for a while.

Here is my "submit" controller, which is what is executed when the form is submitted:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Submit extends CI_Controller {
function index() {
  $this->load->model('Post_model');
  $class_name = $this->input->post('class_name');
  $title = $this->input->post('title');
  $content = $this->input->post('content');
  
  $this->post_model->new_entry($title, $class_name, $content);
}  
}
?>


here is my "post" model:

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Post_model extends CI_Model {
function __construct() {
        parent::__construct();
        $this->load->database();
}

function new_entry($title, $class_name, $content){
  $data = array('entry_name' => $title, "entry_class" => $class_name, "entry_body" => $content);
  if ($this->db->insert("entry", $data)) {
   echo "DB update successful (post_model.php)";
  } else {
   echo "DB update unsuccessful";
  }
}


}
?>


Does anyone see anything off? Thanks.


Help for begginier... Can't figure out problem. - El Forum - 05-31-2012

[eluser]NikosV[/eluser]
try changing
Code:
$this->load->model('Post_model');


with
Code:
$this->load->model('post_model');



Help for begginier... Can't figure out problem. - El Forum - 05-31-2012

[eluser]dkindler[/eluser]
yup. That worked. Thank you!