Jump to content

error in class - confused


geeks

Recommended Posts

I am probably overlooking something simple here, please can you lend me your eyes and tell me what is wrong here , if I call addSessions("user","127.0.0.1" I am getting

 

Fatal error: Call to a member function newGoodlogin() on a non-object in C:\Program Files\wamp\www\LondtPark\includes\class_login.inc on line 193
 

 

in the code snippet it is line 27 --- $this->__userDao->newGoodlogin($username,$this->__ip)

 

here is a snippet of the code :

 

  class userData
  {
    public function newGoodlogin($userName,$ip)
    {                     
      $date = date("Y-m-d"); $time = date("H:i:s");
      return $this->__dao->insert("goodlogs","`ID` , `user_ID` , `date` , `time_start` , `time_end` ,`ip_address`"," NULL , '$userName', '$date', '$time', '', '$ip'");
    }
  }        

  class sessionCookie 
  {
    private $__ip, $__userDao;
    public function __construct($ip)
    { 
      $this->__ip = $ip;
      $__userDao = new userData();
    }


    public function addSessions ($username,$token)
    {
      $_SESSION["loggedin"] = true; 
      $_SESSION["ID"] = $username;
      $date = date("Y-m-d");
      $time = date("H:i:s");  
      $_SESSION["securetoken"] = $token;
      $this->__userDao->newGoodlogin($username,$this->__ip); 
      $_SESSION["goodlogID"] = mysql_insert_id(); 
    }
  }

 

 

Thanks for any help

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/200875-error-in-class-confused/
Share on other sites

Yes, it wont work brother !!! below is the code.. you should use $this->__userDao instead of $__userDao

 

class sessionCookie {
public $__ip, $__userDao;
public function __construct($ip){ 
	$this->__ip = $ip;
	$this->__userDao = new userData();

}


public function addSessions ($username,$token){
	$_SESSION["loggedin"] = true; 
	$_SESSION["ID"] = $username;
	$date = date("Y-m-d");
	$time = date("H:i:s");  
	$_SESSION["securetoken"] = $token;

	$this->__userDao->newGoodlogin($username,$this->__ip); 
	$_SESSION["goodlogID"] = mysql_insert_id(); 
}
}


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.