title: PHP - I'm getting array to string conversion error in codeigniter
body: <p>im trying to have an edit/update module in my system. But, it seems i cant figure it out why im getting array to string conversion error. Below are the model,view,controller codes.</p>
  
  <p>Line error in model</p>
  
  <pre><code>function updatebyid($userid, $data)
  {
      $this-&gt;db-&gt;where('id', $userid); **i get the error in this line in my model**
  </code></pre>
  
  <p>Line error in controller</p>
  
  <pre><code>$userid = $this-&gt;model_user-&gt;get_user_by_id($this-&gt;session-&gt;userdata('id'));
      if ($this-&gt;model_user-&gt;updatebyid($userid, $data)) **AND IN THIS LINE TOO IN MY CONTROLLER**
  </code></pre>
  
  <p>My model</p>
  
  <pre><code>function get_user_by_id($id)
  {
      $this-&gt;db-&gt;where('id', $id);
      $query = $this-&gt;db-&gt;get('users');
      return $query-&gt;result();
  }
  function updatebyid($userid, $data)
  {
      $this-&gt;db-&gt;where('id', $userid);
      $query = $this-&gt;db-&gt;update('users', $data);
      return $query-&gt;result();
      //return $query-&gt;row()-&gt;query;
  }
  </code></pre>
  
  <p>My view</p>
  
  <pre><code>&lt;/div&gt;
      &lt;div class="row well" style="color: black; margin-top: 15px;"&gt;
          &lt;h2&gt;Edit Profile&lt;/h2&gt;
              &lt;?php $attributes = array("name" =&gt; "registerform");
          echo form_open("account/edituserinfo/", $attributes);?&gt;
  
          &lt;div class="form-group"&gt;
  
              &lt;div class="col-sm-4"&gt;
              &lt;label for="fname"&gt;First Name&lt;/label&gt;
              &lt;input class="form-control" name="fname" required type="text" value="&lt;?php echo $fname; ?&gt;" /&gt;
              &lt;span class="text-danger"&gt;&lt;?php echo form_error('fname'); ?&gt;&lt;/span&gt;
              &lt;/div&gt;
  
              &lt;div class="col-sm-4"&gt;
              &lt;label for="mname"&gt;Middle Name&lt;/label&gt;
              &lt;input class="form-control" name="mname" required placeholder="Middle Name" type="text" value="&lt;?php echo $mname; ?&gt;" /&gt;
              &lt;span class="text-danger"&gt;&lt;?php echo form_error('mname'); ?&gt;&lt;/span&gt;
              &lt;/div&gt;
  
              &lt;div class="col-sm-4"&gt;
              &lt;label for="lname"&gt;Last Name&lt;/label&gt;
              &lt;input class="form-control" name="lname" required placeholder="Last Name" type="text" value="&lt;?php echo $lname; ?&gt;" /&gt;
              &lt;span class="text-danger"&gt;&lt;?php echo form_error('lname'); ?&gt;&lt;/span&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  &lt;div class="input-group" style="padding-top: 15px; margin-left: 15px"&gt;
              &lt;button name="submit" type="submit" class="btn btn-success"&gt;Update&lt;/button&gt;
              &lt;!--input class="form-control" name="id" placeholder="id" type="hidden" value="&lt;?php echo $id; ?&gt;" /--&gt;
          &lt;/div&gt;
  
          &lt;?php echo form_close(); ?&gt;
          &lt;?php echo $this-&gt;session-&gt;flashdata('msg'); ?&gt;
      &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>My controller</p>
  
  <pre><code>function index()
  {
      $this-&gt;load-&gt;view('include/headnav');
      $details = $this-&gt;model_user-&gt;get_user_by_id($this-&gt;session-&gt;userdata('id'));
      $data['name'] = $details[0]-&gt;fname . " " . $details[0]-&gt;lname;
      $data['level'] = $this-&gt;session-&gt;userdata('level');
      $data['fname'] = $details[0]-&gt;fname;
      $data['mname'] = $details[0]-&gt;mname;
      $data['lname'] = $details[0]-&gt;lname;
      $data['gender'] = $details[0]-&gt;gender;
      $data['email'] = $details[0]-&gt;email;
      $data['mobileNum'] = $details[0]-&gt;mobileNum;
      $data['landlineNum'] = $details[0]-&gt;landlineNum;
      $data['homeaddress'] = $details[0]-&gt;homeaddress;
      //$data['position'] = $details[0]-&gt;position;
      //$data['institution'] = $details[0]-&gt;institution;
      //$data['institutionAddr'] = $details[0]-&gt;institutionAddr;
      //$data['institutionNum'] = $details[0]-&gt;institutionNum;
      $this-&gt;load-&gt;view('view_account', $data);
      $this-&gt;load-&gt;view('include/footernav');
  }
  function edituserinfo()
  {
      $this-&gt;load-&gt;view('include/headnav');
  
      $data = array(
              'lname' =&gt; $this-&gt;input-&gt;post('lname'),
              'fname' =&gt; $this-&gt;input-&gt;post('fname'),
              'mname' =&gt; $this-&gt;input-&gt;post('mname'),
              'gender' =&gt; $this-&gt;input-&gt;post('gender'),
              'homeaddress' =&gt; $this-&gt;input-&gt;post('homeaddress'),
              'mobileNum' =&gt; $this-&gt;input-&gt;post('mobileNum'),
              //'password' =&gt; $this-&gt;input-&gt;post('password'),
              //'cPassword' =&gt; $this-&gt;input-&gt;post('cPassword'),
              //'institution' =&gt; $this-&gt;input-&gt;post('institution'),
              //'institutionAddr' =&gt; $this-&gt;input-&gt;post('institutionAddr'),
              //'institutionNum' =&gt; $this-&gt;input-&gt;post('institutionNum'),
              //'position' =&gt; $this-&gt;input-&gt;post('position'),
          );
  
      $userid = $this-&gt;model_user-&gt;get_user_by_id($this-&gt;session-&gt;userdata('id'));
      if ($this-&gt;model_user-&gt;updatebyid($userid, $data))
          {
  
              $this-&gt;session-&gt;set_flashdata('msg','&lt;div class="alert alert-success text-center"&gt;Profile edited.&lt;/div&gt;');
              redirect('account/edituserinfo');
          }
          else
          {
              // error
              $this-&gt;session-&gt;set_flashdata('msg','&lt;div class="alert alert-danger text-center"&gt;Error. Check credentials.&lt;/div&gt;');
              redirect('account/edituserinfo');
          }
  }
  
      function updateuinfoview()
  {
      $this-&gt;load-&gt;view('include/headnav');
      $details = $this-&gt;model_user-&gt;get_user_by_id($this-&gt;session-&gt;userdata('id'));
      //$data['fname'] = $details[0]-&gt;fname . " " . $details[0]-&gt;lname;
      $data['fname'] = $details[0]-&gt;fname;
      $data['lname'] = $details[0]-&gt;lname;
      $data['mname'] = $details[0]-&gt;mname;
      $data['gender'] = $details[0]-&gt;gender;
      $data['email'] = $details[0]-&gt;email;
      $data['mobileNum'] = $details[0]-&gt;mobileNum;
      $data['landlineNum'] = $details[0]-&gt;landlineNum;
      $data['homeaddress'] = $details[0]-&gt;homeaddress;
      //$data['position'] = $details[0]-&gt;position;
      //$data['institution'] = $details[0]-&gt;institution;
      //$data['institutionAddr'] = $details[0]-&gt;institutionAddr;
      //$data['institutionNum'] = $details[0]-&gt;institutionNum;
      $this-&gt;load-&gt;view('view_editprofile', $data);
      $this-&gt;load-&gt;view('include/footernav');
  }
  </code></pre>
  
  <p>This is the error message</p>
  
  <blockquote>
    <p>A PHP Error was encountered
    Severity: Notice
    Message: Array to string conversion
    Filename: database/DB_query_builder.php
    Line Number: 669</p>
    
    <p>Backtrace:
    File: C:\xampp\htdocs\THTF.6\application\models\model_user.php
    Line: 73
    Function: where
    File: C:\xampp\htdocs\THTF.6\application\controllers\Account.php
    Line: 74
    Function: updatebyid
    File: C:\xampp\htdocs\THTF.6\index.php
    Line: 315
    Function: require_once</p>
    
    <p>A Database Error Occurred
    Error Number: 1054
    Unknown column 'Array' in 'where clause'
    UPDATE <code>users</code> SET <code>lname</code> = 'Taz', <code>fname</code> = 'Vinny', <code>mname</code> = 'Paz', <code>gender</code> = 'Male', <code>homeaddress</code> = 'USA', <code>mobileNum</code> = '4123' WHERE <code>id</code> = <code>Array</code></p>
    
    <p>Filename: C:/xampp/htdocs/THTF.6/system/database/DB_driver.php
    Line Number: 691</p>
  </blockquote>