title: Codeigniter updating records won't save in DB
body: <p>I'm having some trouble updating records with the Codeigniter framework. I'm using the MVC pattern and active records.</p>
  
  <p>The code is for updating user profiles.</p>
  
  <p>No error but it won't save to my DB. What could be the possible solution for this?</p>
  
  <p><strong>Models (model_users.php)</strong></p>
  
  <pre><code>public function profile_update()
  {
  
      $user_profile = $this-&gt;db-&gt;get('ij_users');
  
      if($user_profile) {
  
          $row = $user_profile-&gt;row();
  
          $data = array(
  
          'user_fname' =&gt; $row-&gt;user_fname,
          'user_lname' =&gt; $row-&gt;user_lname,
          'user_pass' =&gt; $row-&gt;user_pass,
          'user_company' =&gt; $row-&gt;user_company
  
          );
  
          $user_update = $this-&gt;db-&gt;update('ij_users', $data);
      }
  
      if($user_update) {
  
          return true;
  
      }
  
      return false;
  }
  </code></pre>
  
  <p><strong>Controller (members.php)</strong></p>
  
  <pre><code>public function validate()
  {
  
      $this-&gt;load-&gt;library('form_validation');
  
      $this-&gt;form_validation-&gt;set_rules('user_fname', 'First name', 'trim|xss_clean');
      $this-&gt;form_validation-&gt;set_rules('user_lname', 'Last name', 'trim|xss_clean');
      $this-&gt;form_validation-&gt;set_rules('user_pass', 'Password', 'required|trim|xss_clean');
      $this-&gt;form_validation-&gt;set_rules('user_re_pass', 'Re-type Password', 'required|trim|xss_clean|matches[user_pass]');
      $this-&gt;form_validation-&gt;set_rules('user_company', 'Company name', 'trim|xss_clean');
  
      if($this-&gt;form_validation-&gt;run()) {
  
          $this-&gt;load-&gt;model('model_users');
  
          if($this-&gt;model_users-&gt;profile_update()) {
  
              //update database
              //show successfull message
              echo "Successfully saved!";
  
          } else {
  
              //show error updating message
              echo "Problem adding to database 2.";
  
          }
  
      } else {
  
          //show error message
          echo "Problem adding to database.";
      }
  }
  </code></pre>
  
  <p>View (profile.php)</p>
  
  <pre><code>&lt;div class="form-signin"&gt;
  &lt;?php echo form_open('members/validate'); ?&gt;
  
  &lt;?php
    echo '&lt;div class="alert alert-error"&gt;&lt;button type="button" class="close" data-dismiss="alert"&gt;&amp;times;&lt;/button&gt;&lt;h5&gt;All fields are required!&lt;/h5&gt;';
    echo validation_errors();
    echo '&lt;/div&gt;';
  
    echo "&lt;p&gt;&lt;strong&gt;Email address &lt;/strong&gt;&lt;/p&gt;";
    echo form_input('user_email', $this-&gt;input-&gt;post('user_email'), 'disabled');
  
    echo "&lt;p&gt;&lt;strong&gt;First name&lt;/strong&gt;&lt;/p&gt;";
    echo form_input('user_fname', $this-&gt;input-&gt;post('user_fname'));
  
    echo "&lt;p&gt;&lt;strong&gt;Last name&lt;/strong&gt;&lt;/p&gt;";
    echo form_input('user_lname', $this-&gt;input-&gt;post('user_lname'));
  
    echo "&lt;p&gt;&lt;strong&gt;Password &lt;/strong&gt;&lt;/p&gt;";
    echo form_password('user_pass');
  
  
    echo "&lt;p&gt;&lt;strong&gt;Re-type password &lt;/strong&gt;&lt;/p&gt;";
    echo form_password('user_re_pass');
  
    echo "&lt;p&gt;&lt;strong&gt;Company name&lt;/strong&gt;&lt;/p&gt;";
    echo form_input('user_company', $this-&gt;input-&gt;post('user_company'));
  
    echo "&lt;p&gt;";
    echo form_submit('save_submit', 'Save changes', 'class="btn btn-primary"');
    ?&gt;
    &lt;a href="&lt;?php echo base_url() . "members" ?&gt;" class="btn btn-link btn-small"&gt;Cancel&lt;/a&gt;
    &lt;?php
    echo "&lt;/p&gt;";
  
    echo form_close();
  ?&gt;
  </code></pre>
  
  <p></p>