![]() |
Official Blog Tutorial: db->insert insert error with $_POST - 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: Official Blog Tutorial: db->insert insert error with $_POST (/showthread.php?tid=8209) |
Official Blog Tutorial: db->insert insert error with $_POST - El Forum - 05-09-2008 [eluser]php-zbatev[/eluser] hi, I followed the blog tutorial and i am almost through but I'm have this problem with the given insert statement: function comment_insert() { $this->db->insert('comments',$_POST); redirect('blog/comments/'.$_POST['entry_id']); } --------------------------------------------------------------------------------------- and ended up with this error: An Error Was Encountered Error Number: 1054 Unknown column 'Submit_Comment' in 'field list' INSERT INTO `comments` (`entry_id`, `body`, `author`, `Submit_Comment`) VALUES ('1', 'comment nako ni', 'z', 'Submit Query') --------------------------------------------------------------------------------------- the Submit Comment is a submit button: <p><input type="submit" name="Submit Comment"/></p> I think that the error was triggered by $this->db->insert('comments',$_POST); but my question is why did it work in the vid tutorial, where do you think did I miss out? Official Blog Tutorial: db->insert insert error with $_POST - El Forum - 05-09-2008 [eluser]php-zbatev[/eluser] never mind, I got it myself again, I was not suppose to give the submit type input a name so it wouldn't hold a variable to be captured by the $_POST, let me show you why: old(messed up) code: <p><input type="submit" name="Submit Comment"></p> new corrected code: <p><input type="submit" value="Submit Comment"></p> silly, silly me... eheheheh... maybe I just had too much reading, i've been trying to catch up with you guys. :-) Official Blog Tutorial: db->insert insert error with $_POST - El Forum - 05-09-2008 [eluser]optimal[/eluser] That's a nice catch! Official Blog Tutorial: db->insert insert error with $_POST - El Forum - 10-09-2010 [eluser]Unknown[/eluser] Thanks a lot for this post. |