![]() |
Insert db and Error Number: 1054 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Insert db and Error Number: 1054 (/showthread.php?tid=7165) |
Insert db and Error Number: 1054 - El Forum - 03-27-2008 [eluser]zimco[/eluser] I've seen other threads in the forum related to this error and cannot discern if it is: a CI bug, or according to some other threads i'm trying to do something using active records insert that i'm not allowed to do and by reading the user's manual i should see what it is i have done wrong. However, i'm not seeing it. So how can i do a simple insert of an array of values into my database? In my controller i have done this Code: $event=array(); Code: function insert_event($event) { Which results in this: Array ( [0] => 15 [1] => 03/26/1998 [2] => RACE TRACK [3] => $ 500 [4] => NW12501L6 [5] => SLOW [6] => Evening [7] => 1 Mile [8] => FT [9] => 56.0 [10] => 9 ) An Error Was Encountered Error Number: 1054 Unknown column '0' in 'field list' INSERT INTO `race_events` (`0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`) VALUES ('15', ' 03/26/1998 ', ' RACE TRACK ', '$ 500', 'NW12501L6', 'SLOW', ' Evening ', '1 Mile', 'FT', '56.0 ', '9') Insert db and Error Number: 1054 - El Forum - 03-27-2008 [eluser]kgill[/eluser] The obvious thing that stands out is your insert statement, I don't think you named your table columns, 0, 1, 2, 3, etc. instead they probably have useful names like race_date, winnings and so on. Those values need to be in your array so that when it is passed to the db->insert function it sees $event['race_date'] = ‘ 03/26/1998 ‘ not $event[1] = ‘ 03/26/1998 ‘ - K Insert db and Error Number: 1054 - El Forum - 03-27-2008 [eluser]zimco[/eluser] OK, that makes sense. Please excuse my DUH moment. |