Solved

Undefined variable?

Posted on 2000-03-16
6
447 Views
Last Modified: 2008-03-03
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
Comment
Question by:mad_max
  • 3
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
us111 earned 50 total points
ID: 2624518
I guess It's a PHP 4.0 bugs
maybe try
define(pipa, "");
define(dupa, "");
0
 

Author Comment

by:mad_max
ID: 2624765
Right (actually define('dupa',"");) it works fine, thanx. :-)
0
 
LVL 2

Expert Comment

by:gravity
ID: 2629457
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:mad_max
ID: 2631915
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
 

Author Comment

by:mad_max
ID: 2633224
Ok, I gave up after: Warning! Undefined variable HTTP_REFERER in...

Reported as a bug.
Back on php-3.15 ;-)
0
 
LVL 2

Expert Comment

by:gravity
ID: 2633418
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question