Welcome Guest, Not a member yet? Register   Sign In
Need help with Update function
#1

[eluser]AdonisSMU[/eluser]
This is the function from my controller.
Code:
function manage_user($id)
    {
        $this->load->model('musers');
        $this->load->model('muserprofile');
        $user_update = $this->input->post('user_update');    
        
        $data['title'] = 'H.P.N. White Label by TEN || User Update Area';
        $data['main_content'] = 'manage_user';
        $data['login'] = $this->musers->getUser($id);
        $data['info'] = $this->muserprofile->getUserProfile($id);
        if ($user_update == true) {
        
            $user['email'] = $data['login']['email'];
            $user['username'] = $data['login']['username'];
            
            $profile['first_name'] = $data['info']['first_name'];
            $profile['last_name'] = $data['info']['last_name'];
            $profile['company_name'] = $data['info']['company_name'];
            $profile['salutation'] = $data['info']['salutation'];
            $profile['title'] = $data['info']['title'];
            $profile['street_address'] = $data['info']['street_address'];
            $profile['city'] = $data['info']['city'];
            $profile['state'] = $data['info']['state'];
            $profile['zip'] = $data['info']['zip'];
            $profile['country'] = $data['info']['country'];
            $profile['phone'] = $data['info']['phone'];
            
            $login_result = $this->musers->updateUser($id, $user);
            $profile_result = $this->muserprofile->updateUserProfile($id, $profile);
            
            if ($login_result && $profile_result) {
                $data['msg'] = "User profile updated.";
                $data['status'] = "success";
            } else {
                $data['msg'] = "Sorry, user profile not updated.";
                $data['status'] = "error";
            }
        } else {
            $data['msg'] = "";
            $data['status'] = "";
        }
        
        $this->load->view('includes/template', $data);
    }


This is the function from my model.
Code:
function updateUser($id, $users)
    {
        $this->db->where('id', $id);
        $this->db->update('users', $users);
        $result = $this->db->affected_rows();
        
        if($result == 1) {
            return true;
        } else {
            return false;
        }
    }

The $result in the updateUser function is 0 for rows affected and I checked the database and the id matches. Can anyone please help me figure out what I am missing here? Thanks!


Messages In This Thread
Need help with Update function - by El Forum - 02-19-2010, 12:09 AM
Need help with Update function - by El Forum - 02-19-2010, 03:14 AM
Need help with Update function - by El Forum - 02-19-2010, 08:57 AM
Need help with Update function - by El Forum - 02-19-2010, 09:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB