[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