geeks Posted May 6, 2010 Share Posted May 6, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/200875-error-in-class-confused/ Share on other sites More sharing options...
phpchamps Posted May 6, 2010 Share Posted May 6, 2010 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(); } } Quote Link to comment https://forums.phpfreaks.com/topic/200875-error-in-class-confused/#findComment-1054008 Share on other sites More sharing options...
geeks Posted May 6, 2010 Author Share Posted May 6, 2010 oh my Gosh !! I can't believe that I overlooked that hahah thanks !! Quote Link to comment https://forums.phpfreaks.com/topic/200875-error-in-class-confused/#findComment-1054011 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.