title: Undefined property: stdClass::$contents in Code Igniter
body: <p>I was studying and was a following a CodeIgniter Tutorial about database selecting methods. One of it's method was this one.</p>
  
  <p>It was it's Model file called data_model.php:</p>
  
  <pre><code>&lt;?php
      class Data_model extends CI_Model{
          function getAll(){
          $this-&gt;db-&gt;select('title','contents');
          $this-&gt;db-&gt;from('data');
          $this-&gt;db-&gt;where('id',1);           
          $q = $this-&gt;db-&gt;get();
  
          if ($q-&gt;num_rows() &gt; 0){
              foreach($q-&gt;result() as $row){
                  $data[] = $row;
              }
          }
          return $data;           
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Controller File called site.php</p>
  
  <pre><code>&lt;?php
  class Site extends CI_Controller{
      function index(){
          $this-&gt;load-&gt;model('data_model');
          $data['rows'] = $this-&gt;data_model-&gt;getAll();
          $this-&gt;load-&gt;view('home',$data);        
      }   
  }
  ?&gt;
  </code></pre>
  
  <p>and View file called home.php:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;
          &lt;/title&gt;
          &lt;meta http-equiv="Content-Type" content="text/html"; charset=UTF-8&gt;     
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="container"&gt;
              &lt;p&gt;My view has been loaded.&lt;/p&gt;         
              &lt;?php foreach($rows as $r) : ?&gt;
              &lt;h1&gt;&lt;?php echo $r-&gt;title; ?&gt;&lt;/h1&gt;
              &lt;div&gt;&lt;?php echo $r-&gt;contents; ?&gt;&lt;/div&gt;
              &lt;?php endforeach; ?&gt;    
          &lt;/div&gt;
      &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p>When I try to run localhost/ci/ in my browser, an error occurs saying: </p>
  
  <pre><code>A PHP Error was encountered
  Severity: Notice
  Message: Undefined property: stdClass::$contents
  Filename: views/home.php
  Line Number: 13
  </code></pre>
  
  <p>It seems like my $contents variable has no value, but I am pretty sure that my database has contents for each corresponding entry. Just like what the image below shows:</p>
  
  <p><img src="https://i.stack.imgur.com/VLabI.jpg" alt="enter image description here"></p>
  
  <p>Where did I go wrong? The tutorial I was following didn't experience error? Why I am getting this error? </p>