Page 2 of 2

Posted: Thu Jul 11, 2002 9:21 am
by fariquzeli
I still get an undefined variable HTTP_SESSION_VARS

Posted: Thu Jul 11, 2002 9:37 am
by llimllib
do a phpinfo() and try to find your information - that'll tell you what array it's in.

Posted: Thu Jul 11, 2002 9:53 am
by fariquzeli
Tried HTTP_COOKIE_VARS

as well still the same error message
it comes on the second function

Code: Select all

function setUserMessage($message, $error=false) {
session_start();
if ($error) 
	$HTTP_COOKIE_VARS&#1111;'user_message'] = "<font face='verdana,arial'color='red'> $message </font>";
else 
	$HTTP_COOKIE_VARS&#1111;'user_message'] = $message;
&#125;
function printUserMessage() &#123;
	session_start();
	if ($HTTP_COOKIE_VARS&#1111;'user_message'] != "") 
	echo $HTTP_COOKIE_VARS&#1111;'user_message'];
	$HTTP_COOKIE_VARS&#1111;'user_message'] = "";
&#125;

it comes on the first line containing $HTTP_COOKIE_VARS in the second function. Any Ideas?

Posted: Thu Jul 11, 2002 10:04 am
by protokol
Can you post the EXACT error message that you are receiving?

Print the one with $HTTP_SESSION_VARS used

Posted: Thu Jul 11, 2002 10:06 am
by fariquzeli
Warning: Undefined variable: HTTP_SESSION_VARS in /home/ttoomey/pancorp.com/techs/usrl.php on line 13




i even have the functions at the top of the page.

Posted: Fri Jul 12, 2002 1:31 am
by twigletmac
If you're using one of the $HTTP_xxx_VARS arrays you have to declare it as global within your function:

Code: Select all

function setUserMessage($message, $error=false) &#123; 
    global $HTTP_COOKIE_VARS;
    session_start(); 
    if ($error) &#123;
       $HTTP_COOKIE_VARS&#1111;'user_message'] = "<font face='verdana,arial'color='red'> $message </font>"; 
    &#125; else &#123;
       $HTTP_COOKIE_VARS&#1111;'user_message'] = $message; 
    &#125;
&#125;
If you're using PHP version 4.1 or above use $_COOKIE instead (it's autoglobal so you don't have to declare it).

Mac