Jumpy09 Posted February 12, 2010 Share Posted February 12, 2010 RESOLVED: Forgot to re-include the session.php when I changed how the page was called. Simple things like that, but it's a learning experience. Problem: Error: Fatal error: Call to a member function login() on a non-object in ***mysite***/process.php on line 60 function procLogin(){ global $session, $form; /* Login attempt */ $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember'])); /*** Line 60 ***/ /* Login successful */ if($retval){ header("Location: ".$session->referrer); } /* Login failed */ else{ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ".$session->referrer); } } So let me explain a few more things to give you a rough idea of the site layout. I'm using a $_GET method of switching between pages ($include) depending on which page is clicked. The way I have done this the header is always showing. Since the Login Script for process.php uses ""header("Location: ".$session->referrer);"", I cannot call to the process.php page through the same method. I have instead had it called to the process.php page by itself, which is now giving me this error. I dunno what the error means, all I know is it has something to do with the posting methods. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/191873-resolved-fatal-error-call-to-a-member-function-login-on-a-non-object/ Share on other sites More sharing options...
Adam Posted February 12, 2010 Share Posted February 12, 2010 It means $session isn't an object -- where is it declared? Quote Link to comment https://forums.phpfreaks.com/topic/191873-resolved-fatal-error-call-to-a-member-function-login-on-a-non-object/#findComment-1011345 Share on other sites More sharing options...
KevinM1 Posted February 12, 2010 Share Posted February 12, 2010 You're attempting to use $session as though it's an object. PHP is telling you it isn't an object. What is $session supposed to be? Also, never use global variables. Functions and methods have argument lists for a reason, one of which is ensuring that the parameters that are passed in and used in the function/method actually exist. Does $session and/or $form actually exist at the time when you attempt to use them? Quote Link to comment https://forums.phpfreaks.com/topic/191873-resolved-fatal-error-call-to-a-member-function-login-on-a-non-object/#findComment-1011346 Share on other sites More sharing options...
Jumpy09 Posted February 12, 2010 Author Share Posted February 12, 2010 It means $session isn't an object -- where is it declared? The Include for session.php was included in the header.php which is a constant. When I changed how the process.php was called, I forgot to add the include("session.php"); back to the process.php. Since I just woke up, I'm going to let myself slide on that one. But now everything works properly, yay! Quote Link to comment https://forums.phpfreaks.com/topic/191873-resolved-fatal-error-call-to-a-member-function-login-on-a-non-object/#findComment-1011347 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.