[eluser]Michal1[/eluser]
Hi guys,
I am totally new to the codeigniter, so at first I would like to apologise if my question will be kinda stupid.
I have been following nice sets of tutorials, mentioned on nettuts.com. Concretely the crud tutorial. So I tried to make an exact same code as the guy in that tutorial, however it does not work.
What a script should do is, insert some data into a table. There are two forms, title and content and one button submitt. But when I hit the button submit I get this error:
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: data
Filename: models/site_model.php
Line Number: 18
A Database Error Occurred
You must use the "set" method to update an entry.
And I really do not why is that. I looked at the line where a mistake should be, was thinking and tried to change the line:
Code:
function update_record()
{
$this->db->update('data', $data);
}
for:
Code:
function update_record()
{
$this->db->set('data', $data);
}
But it still does not work.
My whole model looks like this:
Code:
<?php
class Site_model extends Model {
function get_records()
{
$query = $this->db->get('data');
return $query->result();
}
function add_record()
{
$this->db->insert('data', $data);
return;
}
function update_record()
{
$this->db->where('id', 12);
$this->db->update('data', $data);
}
function delete_row()
{
$this->db->where('id', $this->url->segment(3));
$this->db->delete('data');
}
}
Does anybody have any input? thank you very much