title: CodeIgniter - Object of class CI_DB_mysqli_result could not be converted to string
body: <p>I'm currently using codeIgniter. I'm trying to update a password in a database according to the email address. Otherwise I got a problem, I use the following code for update my database, that I found on the CodeIgniter website.</p>
  
  <pre><code>$this-&gt;db-&gt;set('field', 'field+1', FALSE);
  $this-&gt;db-&gt;where('id', 2);
  $this-&gt;db-&gt;update('mytable'); // gives UPDATE mytable SET field = field+1 WHERE id = 2
  </code></pre>
  
  <p>The error message I got is </p>
  
  <blockquote>
    <p>Object of class CI_DB_mysqli_result could not be converted to string</p>
  </blockquote>
  
  <p>I found a lot of topic on internet talking about this kind of problem. However, I didn't find anything adapted in my case. As I read before, I've already try to return the result of my query like this</p>
  
  <pre><code>if ($query-&gt;num_rows() == 1)
  {
      return $query-&gt;result();
  }
  else
      return FALSE;
  </code></pre>
  
  <p>Which didn't change anything as you may have guess. So Hopeing somebody will be able to explain me what happen. Here's my model code. I didn't put the whole code, because I thing it will me enough but ask me if you want the rest.</p>
  
  <pre><code>&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  class Reset_password extends CI_Model
  {
      function __construct()
      {
          parent:: __construct();
          $this-&gt;load-&gt;helper('url');
          $this-&gt;load-&gt;helper('string');
      }
  
      function index($email) //function wchich will reset the password in the database;
      {
          $new_password = random_string('alnum', 16);
          //generate random password, already try to remove and put for exemple
          //$new_password = 'lol'; and doesn't work so I suppose this line isn't 
          //the pb
          $this-&gt; db-&gt;set('password', md5($new_password), FALSE);
          $this-&gt; db-&gt;where('email', $email);
          $this-&gt; db-&gt;update('CI_TEST');
  
          $query = $this-&gt;db-&gt;get();
      }
  }
  </code></pre>
  
  <p>Thanks :)</p>
  
  <p>EDIT: Here's my controller code</p>
  
  <pre><code>&lt;?php if (!defined('BASEPATH')) exit('No direct script acess allowed');
  
  class Forget_password extends CI_Controller
  {
      function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;helper(array('form'));
          $this-&gt;load-&gt;model('Reset_password');
          $this-&gt;load-&gt;library('email');
      }
  
      function index()
      {
          $this-&gt;load-&gt;library('form_validation');
          $this-&gt;form_validation-&gt;set_rules('email', 'Email', 'trim|required|valid_email|callback_email_check', 'Error: please provide a valide email adresse');
  
          if ($this-&gt;form_validation-&gt;run() == FALSE)
          {
              $this-&gt;load-&gt;view('Forget_password');
          }
          else
          {
             //loading
          }
      }
  
      function email_check($email)
      {
          $this-&gt; db-&gt;select('email');
          $this-&gt; db-&gt;from('CI_TEST');
          $this-&gt; db-&gt;where('email', $email);
          $this-&gt; db-&gt;limit(1);
  
          $query = $this-&gt; db-&gt;get();
  
          if ($query-&gt;num_rows() == 1)
          {           
              $this-&gt;Reset_password-&gt;index($query);
              return (TRUE);
          }
          else
          {
              echo 'Error: The email you provided doesn\'t exist in the database';
              return (FALSE);
          }
      }
  }
  ?&gt;
  </code></pre>