无法更新数据并存储在数据库中

I have created a registration form with proper validation, and it is getting inserted in to the database. now im trying to update the record but i dont know why my records are not getting updated. please can any one let me know what might be the issue that my records are not getting updated. please m trying it from morning but not getting desired result. even the validation is also not working. please can any one look in to my code and let me know please.

From.php(controller)

public function updatedata()
{
 $id=$this->input->get('id');
 $result['data']=$this->Form_model->displayrecordsById($id);
 $this->load->view('update_records',$result);   

   if($this->input->post('update'))
    {
     $this->form_validation->set_rules('fname', 'First name', 'required');
     $this->form_validation->set_rules('lname', 'Last name', 'required');
     $this->form_validation->set_rules('username', 'Username', 'required|min_length[5]|max_length[12]|is_unique[form.username]');
     $this->form_validation->set_rules('email', 'Email', 'required|valid_email|is_unique[form.email]');

    if ($this->form_validation->run() == TRUE)
    {
        $config['upload_path']   = './uploads/'; 
        $config['allowed_types'] = 'gif|jpg|png'; 
        $this->load->library('upload', $config);

            if($this->upload->do_upload('filename'))
            {
              $fn=$this->input->post('fname');
              $ln=$this->input->post('lname');
              $un=$this->input->post('username');
              $em=$this->input->post('email');
              $fi = $this->upload->data('file_name');
              $this->Form_model->updaterecords($fn,$ln,$un,$em,$fi,$id);
              echo 'Successfully updated your record';
            }
            }
            }
        }

From_model.php

    //get values 
    function displayrecordsById($id)
    {
        $query=$this->db->query("select * from form where ID='".$id."'");
        return $query->result();
    }

    //update record
    function updaterecords($fn,$ln,$un,$em,$fi,$id)
    {
        $query=$this->db->query("update form SET first_name='$fn',last_name='$ln',username='$un',email='$em',filename='$fi' where ID='".$id."'");
    }

update_records.php

    <body>
    <?php
      $i=1;
      foreach($data as $row)
      {
      ?>
        <?php echo form_open_multipart(''); ?>

                <div class="container">

                    <h5 style="color:#ff1a1a">First name</h5>
                    <input type="text" class="form-control" name="fname" value="<?php echo $row->first_name; ?>"/>
                    <span class="text-danger"><?php echo form_error("fname");?></span>

                    <h5 style="color:#ff1a1a">Last name </h5>
                    <input type="text" class="form-control" name="lname" value="<?php echo $row->last_name; ?>"/>
                    <span class="text-danger"><?php echo form_error("lname");?></span>

                    <h5 style="color:#ff1a1a">Username</h5>
                    <input type="text" class="form-control" name="username" value="<?php echo $row->username; ?>"/>
                    <span class="text-danger"><?php echo form_error("username");?></span>

                    <h5 style="color:#ff1a1a">E-mail</h5>
                    <input type="text" class="form-control" name="email" value="<?php echo $row->email; ?>"/>
                    <span class="text-danger"><?php echo form_error("email");?></span>

                    <h5 style="color:#ff1a1a">Image</h5>
                    <img src="<?php echo base_url('uploads/' . $row->filename);?>" class="img-responsive" alt="image" width="100px" height="100px"><br><input type="file" name="filename" value="">

                    <br><input type="submit" name="update" class="btn btn-success" value="Update Records"/></td>

                </div>

        </form>
        <?php } ?>
    </body>

Make sure you load the form validation library in your controller

$this->load->library('form_validation');

Also in your model you should try this for the query:

$queryString ="update form SET first_name='?, last_name= ?, username=?, email=?, filename=? where ID=?"
$this->db->query($queryString, array($fn,$ln,$un,$em,$fi,$id)); 

If your still not getting anything try var_dump($_POST) to make sure you're actually getting your post data.

Let me know if this helps.