after submit page....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post by fariquzeli »

I still get an undefined variable HTTP_SESSION_VARS
User avatar
llimllib
Moderator
Posts: 466
Joined: Mon Jul 01, 2002 2:19 pm
Location: Baltimore, MD

Post by llimllib »

do a phpinfo() and try to find your information - that'll tell you what array it's in.
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post 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?
User avatar
protokol
Forum Contributor
Posts: 353
Joined: Fri Jun 21, 2002 7:00 pm
Location: Cleveland, OH
Contact:

Post by protokol »

Can you post the EXACT error message that you are receiving?

Print the one with $HTTP_SESSION_VARS used
fariquzeli
Forum Contributor
Posts: 144
Joined: Mon Jun 24, 2002 9:16 am
Location: Chicago
Contact:

Post 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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply