Codeigniter 3 is not inserting the data |
I am creating the post via angular 8, but codeigniter is not inserting the data, please have a look of the code, that I have done.
Code: public function add_bankaccount() ERROR - 2019-08-29 15:10:57 --> Query error: Column 'name' cannot be null - Invalid query: INSERT INTO `tbl_bank` (`name`, `bank_name`, `iban`, `user_id`, `status`, `date_added`, `date_modified`) VALUES (NULL, NULL, NULL, NULL, 1, '2019-08-29 15:10:57', '2019-08-29 15:10:57') Please suggest the solution for above. EDIT: moderator added [ code ] tags for readability!!
(08-29-2019, 07:28 AM)php_rocs Wrote: @asheesharyan, It has varchar, also when I print the save_data,it is printing all the data, but after the execution of the query , it convert all the post data to the null...
@asheesharyan,
What is the value of $formdata prior to assigning the values to variables? Also, what is the value of $is_account_exist prior to determining if the account exist?
(08-30-2019, 08:49 AM)php_rocs Wrote: @asheesharyan, $formdata, printing all the post data like bank_name, iban and user_id etc, $is_account_exist, returns the array.
@asheesharyan,
Try this instead. Use your $formdata values to set your $savedata values... $save_data['name']= $formdata['name']; $save_data['bank_name']= $formdata['bank_name']; $save_data['iban']= $formdata['iban']; $save_data['user_id']= $formdata['user_id']; If you are still receiving the same errors then there is something wrong with the $formdata.
$save_data= [];
$save_data['name']=$name; $save_data['bank_name']= $formdata['bank_name']; $save_data['iban']=$formdata['iban']; $save_data['user_id']=$formdata['user_id']; $save_data['status']= 1; $save_data['date_added']= date('Y-m-d H:i'); $save_data['date_modified']= date('Y-m-d H:i'); echo $sql = $this->db->set($save_data)->get_compiled_insert('tbl_bank'); $this->db->query($sql); Output: Please find the attachment
@asheesharyan,
Is it possible to var_dump (dump to the screen) what is in $formdata (I need to see what is in there). The values must be NULL. |
Welcome Guest, Not a member yet? Register Sign In |