title: codeigniter undefined index issue
body: <p>This is fairly simple and I'm even doing something similar in a different part of the site and it works. I'm new to codeigniter so it could be just a simple mistake.</p>
  
  <p>I'm getting this error:</p>
  
  <blockquote>
    <p>Message: Undefined index: username</p>
  </blockquote>
  
  <pre><code>function add($file){
      $user = $this-&gt;session-&gt;userdata('userid');
      $query = $this-&gt;db-&gt;query("SELECT username FROM users WHERE ID = '$user'");
      $result = $query-&gt;result_array();
      echo var_dump($result);
      echo '&lt;br /&gt;';
      echo $result['username'];
      //........
  </code></pre>
  
  <p>When I echo a var_dump, I get the following:</p>
  
  <pre><code>array(1) { [0]=&gt; object(stdClass)#20 (1) { ["username"]=&gt; string(5) "jesse" } }
  </code></pre>