Welcome Guest, Not a member yet? Register   Sign In
strange model behaviour
#1

[eluser]joeizang[/eluser]
hi guys,

sorry I have something strange happening between a model and controller.

Basically I would like to capture comments from the users of the application so having written my code, i get the following the error:

<div id="content">
<h1>A Database Error Occurred</h1>
<p>You must use the "set" method to update an entry.</p>
</div>
but I am not updating, I am just inserting into my db into a table called comments: Here is my code, is there something here that I am not seeing?
(Model)
Code:
function createcomment($data)
{
  $this->db->insert('comments',$data);
  return $this->db->insert();
}

Controller
Code:
function addcomments()
{
$this->form_validation->set_rules('name','Your Name','trim|required|xss_clean');
$this->form_validation->set_rules('email','YourEmailAddress','trim|required|xss_clean|valid_email');
            $this->form_validation->set_rules('comments','Comments','required|trim|xss_clean');
            
if($this->form_validation->run() == FALSE)
{
  echo validation_errors();
} else {
  $data = array(
     'commentname' => $this->input->post('name'),
     'commentemail' => $this->input->post('email'),
     'commentbody' => $this->input->post('comments')
);
$this->comments->createcomment($data);
$this->load->view('editorfiles/successful');
  }
}

Thanks for being great guys


Messages In This Thread
strange model behaviour - by El Forum - 10-11-2009, 01:57 PM
strange model behaviour - by El Forum - 10-11-2009, 02:07 PM
strange model behaviour - by El Forum - 10-11-2009, 02:55 PM
strange model behaviour - by El Forum - 10-11-2009, 03:45 PM
strange model behaviour - by El Forum - 10-11-2009, 04:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB