Page 1 of 1

Session handling

Posted: Thu Oct 07, 2004 3:15 pm
by umcookeg
feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hi 

I am getting this weird error that I have never seen before can any one tell me what might be causing this error.

Code: Select all

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>survey</b> of the object you are trying to operate on was loaded _before_ the session was started in /srv/www/htdocs/Survey/processTrans.php on line 49
I am thinking from the message that it wants me to ensure that I have included the Survey.php page before I try to use the object. Here is my code which might help make this clearer...

Code: Select all

<?php
	global $testSite;
	include_once($testSite . 'globals.php');
	include_once($testSite . 'SiteURLs.php');
	require_once $testSite . 'HTML/IT.php';
	require_once $testSite . 'SUtility.php';
	require_once 'User.php';
	require_once 'buildTransitionPage.php';
	require_once 'buildLogin.php';
	require_once 'Survey.php';                  <--------Survey class def
	
	session_start();      
	session_cache_limiter('private, must-revalidate');
	$try = $_SESSION['cookie'];
	if( $try != "" )
	{

	foreach( $HTTP_POST_VARS as $key=>$value )
	{
		
		if($key == "currQ")
		{
			$nextQues = $HTTP_POST_VARS[$key];
			 
		}//end if
		else if( $key == "random" )
		{
			$random = $HTTP_POST_VARS[$key];
		}//end else if
		else if( $key == "message" )
		{
			$message = $HTTP_POST_VARS[$key];
		}//end else if
		else if( $key == "company" )
		{
			$company = $HTTP_POST_VARS[$key];
			
		}//end else if					
	
		
	}//end foreach
	$suv = $_SESSION['surv'];     <---- get Survey object
	
	if( $suv != "" )                    <---- this passes 
	{
		print"Survey object is set in the session variable suv<BR>";
		$userQuestionNumber = $suv->surveyID;

		$user = $suv->getUser();  <---- BOOOOOOOOOOM!
		
		$suv->qDisplay($nextQues,$message,$company);
	}//end if
	else
	{
		print"Survey object is NOT set in the session variable suv<BR>";
		$message = "Cookies must not be enabled";
		buildLogin($message);
	}//end else.
	}//end outer if
	else
	{
		$message = "You do not have cookies enabled.<BR>";
		$message = $message."This survey requires that cookies be enabled.<BR>";
		$message = $message."Please follow the instructions below to enable cookies for your browser.<BR>";
		buildLogin($message);
	}//end else


?>
Hope somone can help me. Thanks in advance.

Dave


feyd | Please use

Code: Select all

and

Code: Select all

tags where approriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Thu Oct 07, 2004 4:07 pm
by Draco_03
put your session start at top of page..and edit your msg to put

Code: Select all

tag around your php code