Jump to content

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(); 
}
}


This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.