title: Severity: Notice Message: Trying to get property of non-object error to show the data
body: <p>I have a problem with CodeIgniter. This is the message:</p>
  
  <blockquote>
    <p>A PHP Error was encountered</p>
    
    <p>Severity: Notice</p>
    
    <p>Message: Trying to get property of non-object</p>
    
    <p>Filename: views/read.php</p>
    
    <p>Line Number: 89</p>
  </blockquote>
  
  <p>I have a model like this:</p>
  
  <pre class="lang-php prettyprint-override"><code>var $news = 'news';
  
  function read($id)
      {
          $this-&gt;db-&gt;join('category', 'category.id_category = news.id_category');
          $this-&gt;db-&gt;join('editor', 'editor.id_editor = news.id_editor');
          $query = $this-&gt;db-&gt;get_where($this-&gt;news, array('id' =&gt; $id));
          return $query-&gt;row();
      }
  </code></pre>
  
  <p>This is my controller:</p>
  
  <pre class="lang-php prettyprint-override"><code> ...
  $data['news'] = $this-&gt;Newsmodel-&gt;read($id);
  $this-&gt;load-&gt;view('read', $data);
  </code></pre>
  
  <p>And this is my view:</p>
  
  <pre class="lang-php prettyprint-override"><code>...
         &lt;div class="news"&gt;
              &lt;?php  echo $news-&gt;title; ?&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>How to solve this problem?</p>