davidp Posted April 7, 2007 Share Posted April 7, 2007 I am receiving a problem with my session variables in PHP. In essence, PHP thinks that I am trying to use a session variable before it is created. Here is the error itself: Fatal error: Unknown(): The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition <b>account</b> of the object you are trying to operate on was loaded _before_ the session was started in /users/home2/ugrad/d/dpru/public_html/musicstore/site/index.php on line 57 Here is my code, in a bit cut-down form: secure.php ...some code at the beginning, doesnt have to do with sessions.... session_set_cookie_params ( 0, SESSION_PATH, SESSION_DOMAIN ); session_start(); $_SESSION['dumb'] = rand(1, 10); ...a little bit more code follows, but none of it has to do with sessions.... index.php: //Files that need to be included require_once ( "globals.php" ); require_once ( "secure.php" ); require_once ( "functions.php" ); //The DBM require_once ( "../db/dbm.php" ); //Classes to include require_once ( "../classes/account.php" ); //Connect to the database global $dbm; $dbm = new DBM(); // Check if the database is available. if (!$dbm->isConnected()) { print 'Unable to access the database at this time.<p>Sorry for the inconvenience.'; exit; } else print 'Connected!'; if ( !isset($_SESSION['dp_account']) ) $_SESSION['dp_account'] = new Account(); ?> ...some HTML.... <? $_SESSION['dp_account']->displayLoginForm(); ?> ...more stuff The error occurs on that last line where I do displayLoginForm(). To me it looks like I am starting the session, setting the session variables appropriately, and then using them...but obviously I must not be doing so....anyone see an error in my code? Link to comment https://forums.phpfreaks.com/topic/46025-php-sessions-problem/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.