Welcome Guest, Not a member yet? Register   Sign In
no database connection into my custom library
#1

[eluser]Unknown[/eluser]
Hii,

I have a Little problem with my custom libraries.
When i need a database connection in my libraries have i an error.
My database connection is auto-loaded.
Can any body help my?
sorry for my bad English but im dutch.

Error:
Code:
Fatal error: Call to a member function select() on a non-object in /home/deb3052/domains/stijnbourdeaux.com/public_html/dev/application/libraries/auth.php on line 22

My libraries:
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class auth {
    
    public     $CI;
    private $gebruikersnaam;
    private $wachtwoord;
    
    public function __construct() {
        
        $this -> CI =& get_instance();
        
        $this -> gebruikersnaam = $this -> CI -> session -> userdata('gebruikersnaam');
        $this -> wachtwoord        = $this -> CI -> session -> userdata('wachtwoord');
        
    }
    
    private function DB_Gebruiker_check($gebruikersnaam, $wachtwoord) {
        
         $this -> CI -> db -> select('gebruikersnaam', 'wachtwoord');
         $this -> CI -> db -> from('Homeplan_gebruikers');
         $this -> CI -> db -> where('gebruikersnaam', $gebruikersnaam);
         $this -> CI -> db -> where('wachtwoord', $wachtwoord);
         $this -> CI -> db -> limit('1');
        
         $query = $this -> db -> get();
        
         if( $query->num_rows() > 0 ) {
            
             return TRUE;
        
         } else {
            
             return FALSE;
         }
    }
    
    /**
     * INLOGGEN:
     * Functie voor het inloggen van een gebruiker.
     * @param $gebruikersnaam
     * @param $wachtwoord
     */
    public function inloggen($gebruikersnaam, $wachtwoord) {
        
        
        $hash = do_hash($wachtwoord);
        
        if( empty($gebruikersnaam) or empty($wachtwoord) ) {
            
            $return = array('return_code' => '0', 'return_bericht' => 'U hebt uw gebruikersnaam of wachtwoord niet ingevuld!');
            
        } elseif( !$this -> DB_Gebruiker_check($gebruikersnaam, $hash) ) {
            
            $return = array('return_code' => '0', 'return_bericht' => 'De gegevens die u hebt ingevuld kloppen niet!');
            
        } else {
            
            $gebruiker_array = array(    'Gebruikersnaam' => $gebruikersnaam,
                                        'Wachtwoord' => $hash);
            
            $this -> CI -> session -> set_userdata($gebruiker_array);
            
            $return = array('return_code' => '1', 'return_bericht' => 'U bent succesvol ingelogd!');
        }

        return $return;
    }
    
    /**
     *
     * LOGIN_STATUS:
     * Controleerd of de gebruik is ingelogd.
     * Ingelogd: TRUE.
     * Niet-ingelod: FALSE.
     */
    public function login_status() {
        
        if( !$this -> gebruikersnaam OR !$this -> wachtwoord ) {
            
            return FALSE;
        
         } elseif( !$this -> CI -> auth_database -> gebruiker_bestaat($this -> gebruikersnaam, $this -> wachtwoord) ) {
            
             $this -> CI -> session -> sess_destroy();
             return FALSE;
        
         } else {
            
             return TRUE;
         }        
    }
}

/* End of file auth.php */
#2

[eluser]jmadsen[/eluser]
not sure why you get the "select()" error, but

Code:
$query = $this -> db -> get();


should be

Code:
$query = $this -> CI -> db -> get();

everything else (except the missing do_hash() function) worked for me




Theme © iAndrew 2016 - Forum software by © MyBB