Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 465
  • Last Modified:

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
0
mad_max
Asked:
mad_max
  • 3
  • 2
1 Solution
 
us111Commented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now