database - cannot update data in codeigniter -
I can not update my data in the database here My code is:
Controller:
public function update_contact () {sleep (1); $ Data ['validation_error'] = ''; $ This - & gt; Load - & gt; Library ('form_validation'); $ This - & gt; Form_validation - & gt; Set_rules ('name', 'name', 'required | maximum_long [40] | callback_lafa_dish_space'); $ This - & gt; Form_validation - & gt; Set_rules ('email', 'email', 'required | max_lamp [40] | valid_email'); $ This - & gt; Form_validation - & gt; Set_rules ('phone', 'phone', 'required | maximum_long [[15] | alpha_numeric'); $ This- & gt; form_validation- & gt; Set_rules ('cbo_list', 'group name', 'required'); If ($ - - - gt; form_validation -> run () == incorrect) {$ message = "& strong> strong> edit fail!"; $ This - & gt; Json_response (wrong, $ message); } And {$ this - & gt; Contact_model - & gt; Update (& gt; Input -> Post ('name'), $ this -> Input -> Post ('email'), $ this -> Input -> Post ('Phone '), $ This -> Input -> Post (' cbo_list '), $ this -> Session -> User Data (' uid ')); $ Message = "strong & gt;" . $ This - & gt; Input - & gt; post name') . "& Lt; / strong & gt; edited!"; $ This - & gt; Json_response (true, $ message); ("Site / contact") redirect; }} And this is my model:
public function updates ($ cid, $ name, $ email, $ phone, $ cbo_list) {$ (- 'UID' = & gt; $ - -> Session - & gt; User Data ('UID', 'CID' => $ cid)) - & gt; Update ('Contacts', array ('name' = & gt; $ name, 'email' = & gt; $ email, 'phone' = & gt; $ phone, 'gid' = & gt; $ cbo_list)); } For additional information:
My cont name = site, my model name = contact_model, my table = contact and group_contacts where contact.gid = Group_contacts.gid
And before updating your data, you must specify a specific UID (User ID).
If I run it, there is no error, but I can not modify the data. Can any of you help me?
Parameters are incorrect:
$ this -> Contact_model - & gt; Update (& gt; Input -> Post ('name'), $ this -> Input -> Post ('email'), $ this -> Input -> Post ('Phone '), $ This -> Input -> Post (' cbo_list '), $ this -> Session -> User Data (' uid ')); Move the UID to the first parameter position
$ this -> Contact_model - & gt; Update ($ - - this -> session -> User Data ('UID'), $ this -> Input -> Post ('name'), $ this -> Input - & Gt; post ('email'), $ this -> input - & gt; post ('phone'), $ this -> input - & gt; post ('cbo_list')); Alternatively, replace your function with: public function updates ($ cid, $ name, $ email, $ phone, $ cbo_list ) Public function updates ($ name, $ email, $ phone, $ cbo_list, $ cid)
Comments
Post a Comment