Undefined variable?

Sometimes I get those messages:
Warning! Undefined variable dupa in somepage.php3 at line someline. The funniest thing is that it disappears when I restart apache.

And I know I can define empty variable just to stop those messages, but then, if variables are values of form fields I'm going to loose them during submit. (when form action is directed to $PHP_SELF)

I've made a pass-by:
==============
$chceckme="$HTTP_REFERER";
$fromwhere="http://here.is/mypage.php3";
if ($fromwhere!=$checkme) {
$dupa=" ";
$pipa=" ";
}
==============
and it works ok. But I guess there is simpler way?

And of course: Apache/1.3.12/ (UNIX) PHP/4.0b4pl1
mad_maxAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
us111Connect With a Mentor Commented:
I guess It's a PHP 4.0 bugs
maybe try
define(pipa, "");
define(dupa, "");
0
 
mad_maxAuthor Commented:
Right (actually define('dupa',"");) it works fine, thanx. :-)
0
 
gravityCommented:
The problem was most likely to be that in your php.ini file, you've got error reporting set to 8, which reports errors such as unset variables.
Personally, I would have used :

<?
if (!isset($pipa)
   $pipa="";
?>
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
mad_maxAuthor Commented:
Well, I was rebuilding pretty old site, but now I decided to rewrite everything from scratch. I'll post here if the problem persist.
0
 
mad_maxAuthor Commented:
Ok, I gave up after: Warning! Undefined variable HTTP_REFERER in...

Reported as a bug.
Back on php-3.15 ;-)
0
 
gravityCommented:
HTTP_REFERER is only set if a link is clicked on to the page you're using it in.
Also, don't forget that if you're using it in a function, you need to specify it as a global variable with :

function myfunction() {
   global $HTTP_REFERER;
}

I can promise you that this is *not* a bug :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.