Solved

Undefined variable?

Posted on 2000-03-16
6
440 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
Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now