title: CODEIGNITER call to a member function num rows on boolean
body: <p>please i have an issue with codeigniter. when i try to log here is the result:</p>
  
  <h2> Fatal error: Call to a member function num_rows() on boolean in D:\xampp\htdocs\procurementSys\application\models\login_model.php on line 19</h2>
  
  <p>Below tho code of the relative file:</p>
  
  <pre><code>  &lt;?php
  
  
    class Login_model extends CI_Model {
  
  //this function checks whether the username and the password is in the database or not
  public function check_login($username, $password){
  
      $this-&gt;db-&gt;select('username, password, status');
      $array = array('username' =&gt; $username, 'password' =&gt; sha1($password),'status' =&gt; 'active');
      $this-&gt;db-&gt;where($array);
      $query = $this-&gt;db-&gt;get('user');
  
      if($query-&gt;num_rows() == 1) // if the affected number of rows is one
      {
          return true;
      }
      else
      {
          return false;
      }
  }
  
  //this function returns the status of the user to be used in authentication
  public function user_login_data($username, $password){
  
      $this-&gt;db-&gt;select('status');
      $array = array('username' =&gt; $username, 'password' =&gt; sha1($password));
      $this-&gt;db-&gt;where($array);
      $query = $this-&gt;db-&gt;get('user');
  
      if($query-&gt;num_rows() == 1) // if the affected number of rows is one
      {
           $row = $query-&gt;row();
           return $row-&gt;status;
      }
    //        else
    //        {
    //            return false;
    //        }
  }
  
  
  public function user_role($username){ // this function gets the user's role from the database
       $this-&gt;db-&gt;select('role');
       $this-&gt;db-&gt;where('username', $username);
       $query = $this-&gt;db-&gt;get('user');
       $row = $query-&gt;row(0);
  
       return $row-&gt;role;
  }
  
  public function department($username){ // this function gets the user's department from the database
       $this-&gt;db-&gt;select('department');
       $this-&gt;db-&gt;where('username', $username);
       $query = $this-&gt;db-&gt;get('user');
       $row = $query-&gt;row(0); // returns the first row with an array of objects that is stored in the row variable
  
       return $row-&gt;department;
  }
  
  public function get_user_id($username){ // this function gets the user's department from the database
       $this-&gt;db-&gt;select('userID');
       $this-&gt;db-&gt;where('username', $username);
       $query = $this-&gt;db-&gt;get('user');
       $row = $query-&gt;row(0); // returns the first row with an array of objects that is stored in the row variable
  
       return $row-&gt;userID ;
  }
  
  public function fullname($username){
       $this-&gt;db-&gt;select('firstName, secondName');
       $this-&gt;db-&gt;where('username', $username);
       $query = $this-&gt;db-&gt;get('user');
       $row = $query-&gt;row(0);
       return $row;
  
    //            foreach($query-&gt;result() as $row) // returns the query as an array of objects
    //           {
    //                $data[] = $row; // equates the array of objects to an array variable
    //           }
    //        
    //           return $data;
     // }
  }
  
   }
  
   ?&gt;
  </code></pre>
  
  <p>I kept  searching for a solution and found this post (<a href="https://stackoverflow.com/questions/32155636/call-to-a-member-function-num-rows-on-boolean">Call to a member function num_rows() on boolean</a>) . It gave me an idea but no real help. thanks</p>