title: PHP CodeIgniter: Trying to get property of non-object
body: <h1>Everything seems to work just fine but I keep getting the following error:</h1>
  
  <p></p>
  
  A PHP Error was encountered
  
  <p>Severity: Notice</p>
  
  <p>Message:  Trying to get property of non-object</p>
  
  <p>Filename: models/ordermodel.php</p>
  
  <p>Line Number: 24</p>
  
  <p></p>
  
  A PHP Error was encountered
  
  <p>Severity: Notice</p>
  
  <p>Message:  Trying to get property of non-object</p>
  
  <p>Filename: models/ordermodel.php</p>
  
  <p>Line Number: 31</p>
  
  <p></p>
  
  <p>================================================================</p>
  
  <p>In the view i just echo $company_name    </p>
  
  <p>Controller:</p>
  
  <pre><code>            $city = $this-&gt;ordermodel-&gt;get_city($order_reference);
              $customerCompanyName = $this-&gt;ordermodel-&gt;get_company_name($order_reference);
              $data['company_name'] = $customerCompanyName;
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>function get_city($ordernumber) {
      $this-&gt;db-&gt;where('order_number', $ordernumber);
      $city = $this-&gt;db-&gt;get('order');
  
      return $city-&gt;row()-&gt;city;
  }
  
  function get_company_name($ordernumber) {
      $this-&gt;db-&gt;where('order_number', $ordernumber);
      $companyname = $this-&gt;db-&gt;get('order');
  
      return $companyname-&gt;row()-&gt;company_name;
  }
  </code></pre>