title: Trying to get property of non-object error during json encode
body: <p>Here is a piece of code i am trying to write. Here i want to retrieve data from the database, store that into an array and then json_ecode it and set is as output. But i keep on getting this error "Trying to get property of non-object".</p>
  
  <p>Here is the code</p>
  
  <pre><code>$data['query'] = $this-&gt;db-&gt;get('forms');
  
  foreach($data['query'] as $row)
  {
      $forms_array[] = array(
          $row-&gt;id 
      );
  }   
  
  $return=json_encode($forms_array);
  $this-&gt;output-&gt;set_output($return); 
  </code></pre>