Welcome Guest, Not a member yet? Register   Sign In
If All User Group Unchecked Not Updating Database
#1

[eluser]riwakawd[/eluser]
Hi,

I have a user group permission role form.

I am having a slight problem.

When I unselect all my permissions and the click on submit it does not let me clear the permissions from that user group id. and does not redirect back to admin/users_group.

If click all unselect it and then click submit it should clear those permissions from that user group id.

Code:
Error Number: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE user_group_id = '10'' at line 4
UPDATE user_group SET name = 'Demonstration', permission = WHERE user_group_id = '10'
Filename: C:\Xampp\htdocs\codeigniter-project\system\database\DB_driver.php
Line Number: 330

Model edit function

Code:
public function editUserGroup($user_group_id, $data) {
$this->db->query("UPDATE " . $this->db->dbprefix . "user_group SET
name = " . $this->db->escape($data['name']) . ",
permission = " . (isset($data['permission']) ? $this->db->escape(serialize($data['permission'])) : '') . "
WHERE
user_group_id = '" . (int)$user_group_id . "'
");
}

Controller edit function

Code:
public function edit() {
$this->load->model('admin/user/users_group_model');

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {

$user_group_id = $this->uri->segment(4);

$this->users_group_model->editUserGroup($user_group_id, $this->request->post);

$this->session->set_flashdata('success', $this->lang->line('text_success'));

redirect('admin/users_group');

}

$this->getForm();
}


Messages In This Thread
If All User Group Unchecked Not Updating Database - by El Forum - 10-17-2014, 06:51 AM
If All User Group Unchecked Not Updating Database - by El Forum - 10-17-2014, 10:03 AM
If All User Group Unchecked Not Updating Database - by El Forum - 10-17-2014, 08:03 PM
If All User Group Unchecked Not Updating Database - by El Forum - 10-17-2014, 09:26 PM
If All User Group Unchecked Not Updating Database - by El Forum - 10-17-2014, 09:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB