Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Undefined variable?

Posted on 2000-03-16
6
Medium Priority
?
464 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
us111 earned 200 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

719 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