title: CodeIgniter - Array to String conversion error
body: <p>I am creating a function to get a users data based on the user ID. This is the function I have created:</p>
  
  <pre><code>    function getUserData($data, $id) {
          $query = $this-&gt;db-&gt;query('SELECT ' . $data . ' FROM users WHERE id = "' . $id . '"');
  
          return $query-&gt;result();
      }
  </code></pre>
  
  <p>I am calling this method in my home_view.php file: </p>
  
  <pre><code>    &lt;?php $username = $this-&gt;model_users-&gt;getUserData('username', 3); ?&gt;
  </code></pre>
  
  <p>When I do this I get an error saying</p>
  
  <pre><code>A PHP Error was encountered
  
  Severity: Notice
  
  Message: Array to string conversion
  
  Filename: views/home_view.php
  
  Line Number: 25
  </code></pre>
  
  <p>Could someone please tell me why its doing this?</p>