![]() |
Column cannot be null - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Column cannot be null (/showthread.php?tid=1230) |
Column cannot be null - rocks - 02-20-2015 All was working fine until upgraded to CI3. I have a form where users have the option to choose their category from the dropdown. For ex: If they select Cars, a second dropdown populated from database showing input text : Fuel, mileage, year. If they choose Home, Surface, rooms,... Before all that, they have to provide their name, address, zipcode .... So, when the form is submited, it throws an error: Column 'fuel' cannot be null, even Cars wasn't selected. PHP Code: Model PHP Code: public function add($data,$returnid = true) Table structure: PHP Code: CREATE TABLE `biz` ( Thanks RE: Column cannot be null - Avenirer - 02-20-2015 You did define the fuel field in the table not to be null. But when you create the $biz array, you are passing to the 'fuel' key a value from an input element called "about" (which, by the way, is assigned to other 3 keys...), but that element is nowhere to be found in the rules... Make sure you are passing the right form element value to the "fuel" key. RE: Column cannot be null - rocks - 02-20-2015 (02-20-2015, 01:56 PM)Avenirer Wrote: You did define the fuel field in the table not to be null. But when you create the $biz array, you are passing to the 'fuel' key a value from an input element called "about" (which, by the way, is assigned to other 3 keys...), but that element is nowhere to be found in the rules... Make sure you are passing the right form element value to the "fuel" key. Sorry about, just edited the code. Copy and paste (Didn't pay attention). RE: Column cannot be null - rocks - 02-23-2015 This is weird, in CI3 when I check the output of this array, : PHP Code: $biz=$this->get_form_data(); But with CI 2.2.1 this part is different PHP Code: ["fuel"]=> NULL ["kilo"]=> NULL ["carburant"]=> NULL Here is a full output, PHP Code: array(28) { ["city_id"]=> string(1) "3" CI 2.2.1 PHP Code: ["fuel"]=> bool(false) ["kilo"]=> bool(false) ["carburant"]=> bool(false) CI3 PHP Code: ["fuel"]=> NULL ["kilo"]=> NULL ["carburant"]=> NULL Is this related to CI3 database changes? |