title: Fatal error: Call to a member function query() on string
body: <p>I am getting a fatal error, I tried to find a solution in stackoverflow and other forum but I can't seem to find it.</p>
  
  <p>Error looks like:</p>
  
  <blockquote>
    <p>Fatal error: Call to a member function query() on string in
    /home/......./check.php on line 19</p>
  </blockquote>
  
  <pre><code>class M_login extends CI_Model{
      public function num_of_students($name,$adress){     
          $sql="select * from tbl_admin where name='$name' and address='$address'";       
          $query=$this-&gt;db-&gt;query($sql);      
          return $query-&gt;num_rows();
      }
  </code></pre>