I’ve got a form in a Drupal module I’m trying to submit to create an “event”. The events table structure is:
- an event id
- a city id
- an event name
- a created field
- a picture field
- a time field
- a date field
- a data field
- an event type field (which is of type enum)
When I try to create a new event and insert it into the database using:
$eid = db_insert('events')->fields(array(
'cid' => $cid,
'name' => $name,
'time' => $time,
'date' => $timestamp,
'data' => $extra_info,
'event_type' => $checked, //this is an array of checked checkboxes
))->execute();
it throws up an error saying:
PDOException :SQLSTATE[HY093]: Invalid parameter number: parameter was not defined: INSERT INTO {events} (cid, name, time, date, data, event_type) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5_Games, :db_insert_placeholder_5_Other); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => Name [:db_insert_placeholder_2] => 23.30 [:db_insert_placeholder_3] => 1313020800 [:db_insert_placeholder_4] => More [:db_insert_placeholder_5_Games] => Games [:db_insert_placeholder_5_Other] => Other ) in event_creation_submit().
Any ideas as to what I’m doing wrong?
Thanks
Managed to fix the situation.
Changed the type of the
event_typefield to a set and passed it a string of values instead of an array. This solved it.Thanks for everyone’s help though!