active record and $_POST error... - 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: active record and $_POST error... (/showthread.php?tid=3245) |
active record and $_POST error... - El Forum - 09-19-2007 [eluser]JP X3M[/eluser] CodeIgniter newbie here... ^__^ im having problems with the method in the video create a blog in 20 minutes... why does the function function comment_insert(){ $this->db->insert('comments',$_POST); } it wants to insert even the submit button... but naturally it will not be found on the database and so generates an error 1054 Unknown column 'Post_Comment' in 'field list' thanks in advance.. im sorry for asking such noobish question,,, ^__^ active record and $_POST error... - El Forum - 09-19-2007 [eluser]ELRafael[/eluser] [quote author="JP X3M" date="1190238735"]CodeIgniter newbie here... ^__^ im having problems with the method in the video create a blog in 20 minutes... why does the function function comment_insert(){ $this->db->insert('comments',$_POST); } it wants to insert even the submit button... but naturally it will not be found on the database and so generates an error 1054 Unknown column 'Post_Comment' in 'field list' thanks in advance.. im sorry for asking such noobish question,,, ^__^[/quote] hum... in the video, doesn't have name (name='Post_Comment') in the submitt button. :cheese: but, for security reason, you need to validate the post that you received. Be carefull when you use $this->db->insert('table', $_POST); active record and $_POST error... - El Forum - 09-19-2007 [eluser]Michael Wales[/eluser] Yeah, I definitely would not just dump the $_POST array into that field. Here's what you should (and it will give you some practice working with CI! 1. Create an array named (I usually call it $insert) where each key is the name of a column in your record that corresponds to the value from the posted form. 2. Use Active Record to insert this array. Here's a code example really quick - I've never watched the blog tutorial so I can't use the same fields but you'll get the idea: Code: $insert = array{'title' => $this->input->post('title'), active record and $_POST error... - El Forum - 09-19-2007 [eluser]JP X3M[/eluser] thanks for the reply... ^__^ i was just trying it anyway... i was just doing it step by step to familiarize with the environment... gonna try your idea right away! active record and $_POST error... - El Forum - 09-21-2007 [eluser]Unknown[/eluser] I ran into this same thing. I did follow the directions above, and it works perfectly. But what I'm kinda confused about is when I first followed the tutorial, things worked fine. The database would get updated, etc... But when I added FCKEditor to the mix, suddenly I got the error that he got. I understand the security issues, but I'm just not sure why that the error showed up only AFTER I changed the "body" field to include rich text. If anyone could shed some light on this it may prevent a problem I might run into at a later date. Afterall I'm trying to learn CI and this is perplexing to me active record and $_POST error... - El Forum - 09-21-2007 [eluser]Michael Wales[/eluser] It's been awhile since I used FCKEditor, but I believe it dynamically generates some additional fields on your form (these are hidden from normal view). The error occurs when attempting to insert the $_POST array, these new-found fields are being insert as well. CI and MySQL go "wtf?" because those fields are not found in your database. active record and $_POST error... - El Forum - 01-05-2008 [eluser]meovino[/eluser] JP -- Glad I'm not the only one having this problem. Thought I was going nuts. Makes sense that the $_POST array would have the submit button in it. I just can't figure out how it works for Derek. active record and $_POST error... - El Forum - 01-07-2008 [eluser]Negligence[/eluser] Just do this... Code: unset($_POST['submit']); |