[newbie] $this->db->insert(); problem - 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: [newbie] $this->db->insert(); problem (/showthread.php?tid=11843) |
[newbie] $this->db->insert(); problem - El Forum - 09-25-2008 [eluser]Ingonyama[/eluser] Hi, Im trying to use the insert method but its looking for a "submit" column in the database (obviously from the submit button). Error message is: "Unknown column 'submit' in 'field list'" INSERT INTO `categories` (`name`, `description`, `submit`) VALUES ('test', 'test123', '') Controller: Code: function add_category() View: Code: <h1><?php echo $heading; ?></h1> Thanks for any help. [newbie] $this->db->insert(); problem - El Forum - 09-25-2008 [eluser]xwero[/eluser] It's very tempting to add POST to the fields parameter but you have to be aware there could be other fields in the form that are not for the database. So it's best to hardcode the values you need for the fields or you could use the $this->db->list_fields() method to filter the POST global. [newbie] $this->db->insert(); problem - El Forum - 09-25-2008 [eluser]Ingonyama[/eluser] Thanks that makes sense, I just hardcoded it in. |