Undefined variable: data and You must use the "set" method to update an entry. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Undefined variable: data and You must use the "set" method to update an entry. (/showthread.php?tid=37489) |
Undefined variable: data and You must use the "set" method to update an entry. - El Forum - 01-11-2011 [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 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() for: Code: function update_record() But it still does not work. My whole model looks like this: Code: <?php Does anybody have any input? thank you very much Undefined variable: data and You must use the "set" method to update an entry. - El Forum - 01-11-2011 [eluser]Cristian Gilè[/eluser] Hi Michal1, how do you pass $data to the update function? You need to change your code from Code: function update_record() to Code: function update_record($data) Change other functions accordingly. Cristian Gilè Undefined variable: data and You must use the "set" method to update an entry. - El Forum - 01-11-2011 [eluser]Michal1[/eluser] Ah I see. Thank you very much. I thought that because I have: Code: $this->site_model->add_record($data); Could you please explain why it is not? Thank you M Undefined variable: data and You must use the "set" method to update an entry. - El Forum - 01-11-2011 [eluser]Cristian Gilè[/eluser] This is a basic programming question related to PHP not CI. Cristian Gilè |