title: Call to a member function num_rows() on a non-object in codeigniter
body: <p>i have a problem when i want tou run a function from my controller its said "Call to a member function num_rows() on a non-object".</p>
  
  <p>this is my function named category from my web.php controller</p>
  
  <pre><code>public function categori($id){
      $cek = $this-&gt;mymodel-&gt;GetKategori("where kode_kategori = '$id'");
      if ($cek-&gt;num_rows() &gt; 0) {
          $data = array(
          "produk_populers" =&gt; $this-&gt;mymodel-&gt;GetProduk("where kode_kategori = '$id'")-&gt;result_array()
          );
  
          $comp = array(
              "header" =&gt; $this-&gt;html_header(),
              "navbar" =&gt; $this-&gt;html_navbar(),
              "produk_populer" =&gt; $this-&gt;load-&gt;view("produk_populer",$data,true),
              "kategori" =&gt; $this-&gt;html_kategori(),
              "footer" =&gt; $this-&gt;html_footer(),
          );
          $this-&gt;load-&gt;view("index",$comp);
  
      }else{
          show_404(); 
  
    }
  
  } 
  </code></pre>
  
  <p>and this the model</p>
  
  <pre><code>&lt;?php
  defined('BASEPATH') OR exit('No direct script access allowed');
  
  class Mymodel extends CI_Model {
  public function GetProduk($where=""){
      $data = $this-&gt;db-&gt;query('select * from produk'.$where);
      return $data;
  
  }
  
  public function GetKategori($where=""){
      $data = $this-&gt;db-&gt;query('select * from kategori '.$where);
      return $data -&gt; result_array();
  }
  
  }
  </code></pre>
  
  <p>can anyone tell me what's wrong with it? i'm new with this kind of stuff.. thanks</p>