Re: [PHP] Undefined Variables

2013-02-14 Thread Ashley Sheridan


Roman Gelfand rgelfa...@gmail.com wrote:

Is there a performance hit when a variable is undefined? or, perhaps,
aside from the obvious uncontrolled conditions, are there other
impacts?

Thanks in advance

Aside from all the warnings and potential logic bombs?

You will have a negligible performance hit with all the isset() checks you'll 
be using, but they won't be noticeable, and its preferred to use them than not 
to avoid issues with missing values.
Thanks,
Ash
http://www.ashleysheridan.co.uk

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Undefined Variables

2013-02-14 Thread Matijn Woudt
On Thu, Feb 14, 2013 at 7:04 PM, Roman Gelfand rgelfa...@gmail.com wrote:

 Is there a performance hit when a variable is undefined? or, perhaps,
 aside from the obvious uncontrolled conditions, are there other
 impacts?

 Thanks in advance


There might be a little performance hit because the error is getting logged
in your webservers logs, though if it is noticeable depends on which
webserver you're using, and how often there are undefined variables.

- Matijn


Re: [PHP] Undefined Variables

2013-02-14 Thread Jan Ehrhardt
Matijn Woudt in php.general (Thu, 14 Feb 2013 19:12:55 +0100):
On Thu, Feb 14, 2013 at 7:04 PM, Roman Gelfand rgelfa...@gmail.com wrote:

 Is there a performance hit when a variable is undefined? or, perhaps,
 aside from the obvious uncontrolled conditions, are there other
 impacts?

There might be a little performance hit because the error is getting logged
in your webservers logs, though if it is noticeable depends on which
webserver you're using, and how often there are undefined variables.

And frameworks like Drupal might intercept the error and store it in the
watchdog file. Then the performance will be degraded.

Jan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Undefined Variables

2013-02-14 Thread Stuart Dallas
Sorry for the top post!

I don't know numbers, but my gut instinct is that the cycles wasted raising the 
notice (it gets raised even if it goes nowhere so turning display and log 
doesn't remove the hit completely) are better spent executing defensive code.

There is no reason, ever, that production code should raise notices about which 
you don't care. If PHP is telling you something might be wrong, something might 
be wrong! And if you're investigating the code already, figure out what's 
happening and deal with it properly.

Only lazy and/or developers ignore notices. If you're one of them and this 
statement offends you, you probably know it's right!

-Stuart

-- 
Sent from my leaf blower

On 14 Feb 2013, at 18:04, Roman Gelfand rgelfa...@gmail.com wrote:

 Is there a performance hit when a variable is undefined? or, perhaps,
 aside from the obvious uncontrolled conditions, are there other
 impacts?
 
 Thanks in advance
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Undefined Variables

2013-02-14 Thread Al



On 2/14/2013 1:54 PM, Stuart Dallas wrote:

Sorry for the top post!

I don't know numbers, but my gut instinct is that the cycles wasted raising the 
notice (it gets raised even if it goes nowhere so turning display and log 
doesn't remove the hit completely) are better spent executing defensive code.

There is no reason, ever, that production code should raise notices about which 
you don't care. If PHP is telling you something might be wrong, something might 
be wrong! And if you're investigating the code already, figure out what's 
happening and deal with it properly.

Only lazy and/or developers ignore notices. If you're one of them and this 
statement offends you, you probably know it's right!

-Stuart



I agree with Stuart.

To minimize the overhead of testing every possible undefined variable with 
isset(), I assign them at the top of the page which uses them. e.g.,


$userInstrHtmlSizeWarning = false;
$currentUserRecArray = array();
if(!isset($_SESSION['pwPassed']))$_SESSION['pwPassed'] = false;

I also have this snippet at the top of my app config file.

if(true){ // TRUE for debug only
  ini_set(display_errors, on); //use off if users will see them
  error_reporting(E_ALL)
  $error_reporting = 'span style=color:redError display and logging 
on/span  ';

}
else $error_reporting=null;

I put this at a convenient place on the page so I don't forget to turn off the 
error reporting when the code goes live.


if($error_reporting) echo $error_reporting;

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Undefined Variables

2013-02-14 Thread Stuart Dallas
On 14 Feb 2013, at 20:57, Al n...@ridersite.org wrote:
 On 2/14/2013 1:54 PM, Stuart Dallas wrote:
 Sorry for the top post!
 
 I don't know numbers, but my gut instinct is that the cycles wasted raising 
 the notice (it gets raised even if it goes nowhere so turning display and 
 log doesn't remove the hit completely) are better spent executing defensive 
 code.
 
 There is no reason, ever, that production code should raise notices about 
 which you don't care. If PHP is telling you something might be wrong, 
 something might be wrong! And if you're investigating the code already, 
 figure out what's happening and deal with it properly.
 
 Only lazy and/or developers ignore notices. If you're one of them and this 
 statement offends you, you probably know it's right!
 
 -Stuart
 
 
 I agree with Stuart.
 
 To minimize the overhead of testing every possible undefined variable with 
 isset(), I assign them at the top of the page which uses them. e.g.,
 
 $userInstrHtmlSizeWarning = false;
 $currentUserRecArray = array();
 if(!isset($_SESSION['pwPassed']))$_SESSION['pwPassed'] = false;
 
 I also have this snippet at the top of my app config file.
 
 if(true){ // TRUE for debug only
  ini_set(display_errors, on); //use off if users will see them
  error_reporting(E_ALL)
  $error_reporting = 'span style=color:redError display and logging 
 on/span  ';
 }
 else $error_reporting=null;
 
 I put this at a convenient place on the page so I don't forget to turn off 
 the error reporting when the code goes live.
 
 if($error_reporting) echo $error_reporting;

I've used the following method for accessing elements of the global arrays for 
a long time. It saves a lot of typing!

http://stut.net/2011/04/12/php-snippet-array-element-access/

Note that if you're using PHP5 you should remove the  before the $a in the 
function definition.

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP: Undefined Variables Error Message

2004-08-27 Thread Michal Migurski
Hello all. I just finished placing a new server in production and 
PHP is not working. I am getting undefined variable messages when 
trying to submit php based forms. Register Globals is on in 
php.ini, but it still does not work. I have even tried copying a 
known-good php.ini from another server and the same behavior 
exists. I am running IIS in Windows 2000. Any ideas?

Another website dies on line 4 here:
?php
$to = [EMAIL PROTECTED];
$subject = Swinos.com Booking Contact - $name;
$headers .= MIME-Version: 1.0\r\n;
$headers .= '...';
is equivalent to
$headers = $headers . '...';
So it's probably complaining that $headers is not defined when you're 
trying to append something to it. Change that first .= to a =, like 
the line above, and see if that doesn't help.

--
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread Jeff - Webmaster
Hello all. I just finished placing a new server in production and PHP is 
not working. I am getting undefined variable messages when trying to submit 
php based forms. Register Globals is on in php.ini, but it still does not 
work. I have even tried copying a known-good php.ini from another server 
and the same behavior exists. I am running IIS in Windows 2000. Any ideas?

Jeff
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread John Holmes
From: Jeff - Webmaster [EMAIL PROTECTED]
Hello all. I just finished placing a new server in production and PHP is 
not working. I am getting undefined variable messages when trying to 
submit php based forms. Register Globals is on in php.ini, but it still 
does not work. I have even tried copying a known-good php.ini from another 
server and the same behavior exists. I am running IIS in Windows 2000. Any 
ideas?
Does the output of phpinfo() show that register_globals is ON?
---John Holmes... 

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread Greg Donald
On Thu, 2004-08-26 at 12:55, Jeff - Webmaster wrote:
 Hello all. I just finished placing a new server in production and PHP is 
 not working. I am getting undefined variable messages when trying to submit 
 php based forms. Register Globals is on in php.ini, but it still does not 
 work. I have even tried copying a known-good php.ini from another server 
 and the same behavior exists. I am running IIS in Windows 2000. Any ideas?


Is your error_reporting turned up too high for the quality of the code?

http://www.php.net/error_reporting



-- 
Greg Donald

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread Jeff - Webmaster
The error reporting level is the same as it was for the same websites on a 
different server that is working.

Jeff
At 11:49 AM 8/26/2004, Greg Donald wrote:
On Thu, 2004-08-26 at 12:55, Jeff - Webmaster wrote:
 Hello all. I just finished placing a new server in production and PHP is
 not working. I am getting undefined variable messages when trying to 
submit
 php based forms. Register Globals is on in php.ini, but it still does not
 work. I have even tried copying a known-good php.ini from another server
 and the same behavior exists. I am running IIS in Windows 2000. Any ideas?

Is your error_reporting turned up too high for the quality of the code?
http://www.php.net/error_reporting

--
Greg Donald
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread John Nichel
Jeff - Webmaster wrote:
Hello all. I just finished placing a new server in production and PHP is 
not working. I am getting undefined variable messages when trying to 
submit php based forms. Register Globals is on in php.ini, but it still 
does not work. I have even tried copying a known-good php.ini from 
another server and the same behavior exists. I am running IIS in Windows 
2000. Any ideas?

Jeff
Chances are you just have error reporting set to show warnings/notices 
as well as errors.  Check the php.ini for this.  While it is best to 
code so that you won't have these notices popping up, most will tell you 
to turn down error reporting on a production server.

What would cause something like this is if I have a checkbox in a form 
on one page, and I don't have it checked when I submit the form, that 
variable won't be sent...so if I try to do something with that variable, 
I'll get this warning.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread John Holmes
From: Jeff - HarborNet [EMAIL PROTECTED]
Hello all. I just finished placing a new server in production and PHP is 
not working. I am getting undefined variable messages when trying to 
submit php based forms. Register Globals is on in php.ini, but it still 
does not work. I have even tried copying a known-good php.ini from 
another server and the same behavior exists. I am running IIS in Windows 
2000. Any ideas?
Does the output of phpinfo() show that register_globals is ON?
Yes it does show as being on.
Sorry, I forgot to also put:
and if it is on, show some code that produces the message you're talking 
about. If it says $var is undefined, where to you define $var or how do you 
think/feel $var is being defined?

I have mind reading turned off for the time being.
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread Jeff - Webmaster
Here is a snippet of the code that is being choked on. The first failure 
comes from line 6:

?php
$name = $_POST['name'];
$address = $_POST['address'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$type = $_POST['type'];
$message = $_POST['message'];
The variables are being passed from an html form that calls this script 
with the post method.

Jeff
At 12:06 PM 8/26/2004, John Holmes wrote:
From: Jeff - HarborNet [EMAIL PROTECTED]
Hello all. I just finished placing a new server in production and PHP 
is not working. I am getting undefined variable messages when trying to 
submit php based forms. Register Globals is on in php.ini, but it still 
does not work. I have even tried copying a known-good php.ini from 
another server and the same behavior exists. I am running IIS in 
Windows 2000. Any ideas?
Does the output of phpinfo() show that register_globals is ON?
Yes it does show as being on.
Sorry, I forgot to also put:
and if it is on, show some code that produces the message you're talking 
about. If it says $var is undefined, where to you define $var or how do 
you think/feel $var is being defined?

I have mind reading turned off for the time being.
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread Jeff - Webmaster
Another website dies on line 4 here:
?php
$to = [EMAIL PROTECTED];
$subject = Swinos.com Booking Contact - $name;
$headers .= MIME-Version: 1.0\r\n;
$headers .= Content-type: text/html; charset=iso-8859-1\r\n;
$headers .= From: swinos.com [EMAIL PROTECTED]\r\n;
$headers .= Reply-To: .$name. .$email.\r\n;
$headers .= X-Priority: 1\r\n;
$headers .= X-MSMail-Priority: High\r\n;
$headers .= X-Mailer: iCEx Networks HTML-Mailer v1.0;
$subject = stripslashes($subject);
$message = stripslashes($message);
$body = font face=Arial size=-1b$name/b has submited a 
Booking Request. brbr
Name: b$name/b br
Email address: $email br
Phone: $phone br
Business Name: $business br
Venue: $venue brbr
Comments: br$comments;
$success = @mail($to,$subject,$body,$headers);
?

At 12:06 PM 8/26/2004, John Holmes wrote:
From: Jeff - HarborNet [EMAIL PROTECTED]
Hello all. I just finished placing a new server in production and PHP 
is not working. I am getting undefined variable messages when trying to 
submit php based forms. Register Globals is on in php.ini, but it still 
does not work. I have even tried copying a known-good php.ini from 
another server and the same behavior exists. I am running IIS in 
Windows 2000. Any ideas?
Does the output of phpinfo() show that register_globals is ON?
Yes it does show as being on.
Sorry, I forgot to also put:
and if it is on, show some code that produces the message you're talking 
about. If it says $var is undefined, where to you define $var or how do 
you think/feel $var is being defined?

I have mind reading turned off for the time being.
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread John Nichel
John Holmes wrote:
I have mind reading turned off for the time being.
It's a good thing I'm a nice guy. ;)
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread John Holmes
Jeff - Webmaster wrote:
Another website dies on line 4 here:
$headers .= MIME-Version: 1.0\r\n;
Well, in this case it's becaue $headers is undefined, yet you're trying 
to concatinate another string to it. Thus the warning...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread John Nichel
Jeff - Webmaster wrote:
Here is a snippet of the code that is being choked on. The first failure 
comes from line 6:

?php
$name = $_POST['name'];
$address = $_POST['address'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$type = $_POST['type'];
$message = $_POST['message'];
The variables are being passed from an html form that calls this script 
with the post method.

Jeff
If you're going to use the super-global $_POST, why do you need globals on?
Anyway, how is 'type' passed from the previous page?  Show the code for 
that.  What type of form field is it?

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread Jeff - Webmaster
Intersting. This is the same pair of html and php files that was functional 
on another server. Can you think of any reason that could account for the 
difference?

Jeff
At 01:51 PM 8/26/2004, John Holmes wrote:
Jeff - Webmaster wrote:
Another website dies on line 4 here:
$headers .= MIME-Version: 1.0\r\n;
Well, in this case it's becaue $headers is undefined, yet you're trying to 
concatinate another string to it. Thus the warning...

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals ­ www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread John Holmes
Jeff - Webmaster wrote:
Intersting. This is the same pair of html and php files that was 
functional on another server. Can you think of any reason that could 
account for the difference?
default error_reporting levels...
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread Jeff - Webmaster
Removing the . got rid of most of the errors, but two remain:
Notice: Undefined variable: headers in E:\domains\swinos\contact.php on line 4
Notice: Undefined variable: message in E:\domains\swinos\contact.php on 
line 12

The offending lines are:
4 - $headers = MIME-Version: 1.0\r\n;
and
12 - $message = stripslashes($message);
Jeff
At 02:32 PM 8/26/2004, Michal Migurski wrote:
Hello all. I just finished placing a new server in production and PHP 
is not working. I am getting undefined variable messages when trying 
to submit php based forms. Register Globals is on in php.ini, but it 
still does not work. I have even tried copying a known-good php.ini 
from another server and the same behavior exists. I am running IIS in 
Windows 2000. Any ideas?

Another website dies on line 4 here:
?php
$to = [EMAIL PROTECTED];
$subject = Swinos.com Booking Contact - $name;
$headers .= MIME-Version: 1.0\r\n;
$headers .= '...';
is equivalent to
$headers = $headers . '...';
So it's probably complaining that $headers is not defined when you're 
trying to append something to it. Change that first .= to a =, like 
the line above, and see if that doesn't help.

--
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread John Holmes
Jeff - Webmaster wrote:
Removing the . got rid of most of the errors, but two remain:
Notice: Undefined variable: headers in E:\domains\swinos\contact.php on 
line 4

Notice: Undefined variable: message in E:\domains\swinos\contact.php on 
line 12

The offending lines are:
4 - $headers = MIME-Version: 1.0\r\n;
and
12 - $message = stripslashes($message);
Line 4 would not produce that message.
If $message is undefined, how are you going to stripslashes from it?
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread Jeff - Webmaster
Turned out to be something different about PHP 4.3.8 vs. 4.3.4. That was 
the only difference between the two servers. As soon as I corrected that, 
all files are working like they used to. Thanks for your help.

Jeff
At 05:22 PM 8/26/2004, John Holmes wrote:
Jeff - Webmaster wrote:
Intersting. This is the same pair of html and php files that was 
functional on another server. Can you think of any reason that could 
account for the difference?
default error_reporting levels...
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals ­ www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP: Undefined Variables Error Message

2004-08-26 Thread Justin Patrin
On Thu, 26 Aug 2004 14:47:17 -0700, Jeff - Webmaster
[EMAIL PROTECTED] wrote:
 Removing the . got rid of most of the errors, but two remain:
 
 Notice: Undefined variable: headers in E:\domains\swinos\contact.php on line 4
 
 Notice: Undefined variable: message in E:\domains\swinos\contact.php on
 line 12
 
 The offending lines are:
 
 4 - $headers = MIME-Version: 1.0\r\n;
 
 and
 

if(isset($message)) {

 12 - $message = stripslashes($message);

}

 
 Jeff
 
 
 At 02:32 PM 8/26/2004, Michal Migurski wrote:
 Hello all. I just finished placing a new server in production and PHP
 is not working. I am getting undefined variable messages when trying
 to submit php based forms. Register Globals is on in php.ini, but it
 still does not work. I have even tried copying a known-good php.ini
 from another server and the same behavior exists. I am running IIS in
 Windows 2000. Any ideas?
 
 Another website dies on line 4 here:
 
 ?php
  $to = [EMAIL PROTECTED];
  $subject = Swinos.com Booking Contact - $name;
  $headers .= MIME-Version: 1.0\r\n;
 
  $headers .= '...';
 
 is equivalent to
 
  $headers = $headers . '...';
 
 So it's probably complaining that $headers is not defined when you're
 trying to append something to it. Change that first .= to a =, like
 the line above, and see if that doesn't help.
 
 --
 michal migurski- contact info and pgp key:
 sf/cahttp://mike.teczno.com/contact.html
 
 
 !DSPAM:412e071553131102431894!
 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Undefined variables?

2002-11-18 Thread Martin Magnusson
I installed php 4.2.3 on Apache2.

When I write ? echo $anyvariable; ? I get an error message telling me that
I have an undefined variable $anyvariable. Is this something new that one
must declare all variables?

In my previous version of php the expression above would return an empty
string - no error messages...

Hope you understand my problem...

Martin Magnusson




Re: [PHP] Undefined variables?

2002-11-18 Thread Ernest E Vogelsinger
At 15:57 18.11.2002, Martin Magnusson spoke out and said:
[snip]
I installed php 4.2.3 on Apache2.

When I write ? echo $anyvariable; ? I get an error message telling me that
I have an undefined variable $anyvariable. Is this something new that one
must declare all variables?

In my previous version of php the expression above would return an empty
string - no error messages...
[snip] 

This is defined by the setting of error_reporting in your php.ini file.
What you get is not an error but a notice message that you are using an
undefined variable.

This can be handy if you want to spot the error when your script doesn't
behave like it should... anyway, to turn it off:

- in php.ini:
  error_reporting = E_ALL  ~E_NOTICE

- in your script:
  error_reporting(E_ALL  ~E_NOTICE);

- avoiding this:
  if (isset($anyvariable)) echo $anyvariable;


-- 
   O Ernest E. Vogelsinger 
   (\) ICQ #13394035 
^ http://www.vogelsinger.at/



Re: [PHP] Undefined variables?

2002-11-18 Thread Maxim Maletsky

set error reporting to 55


--
Maxim Maletsky
[EMAIL PROTECTED]



Martin Magnusson [EMAIL PROTECTED] wrote... :

 I installed php 4.2.3 on Apache2.
 
 When I write ? echo $anyvariable; ? I get an error message telling me that
 I have an undefined variable $anyvariable. Is this something new that one
 must declare all variables?
 
 In my previous version of php the expression above would return an empty
 string - no error messages...
 
 Hope you understand my problem...
 
 Martin Magnusson
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Undefined variables?

2002-10-10 Thread Justoman

I get this with almost all the scripts I run,

It's a whole shit load of undefined variables! what are these and please,
how can they be fixed?

Here's what I'm talkin bout,
http://www.darkwatchclan.com/battlestats/bfserverinfo.php

-Justoman



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables?

2002-10-10 Thread Marco Tabini

Of course, you should switch to UNIX :-)

Seriously, have you looked at the source on those lines? Can you post
the source code otherwise so we can take a look and let you know?

The error you are receiving usually means that a variable is used
without having been initialized. For example:

$b = $a * 10;

Will cause a warning if $a is not set to something.


Marco

On Thu, 2002-10-10 at 16:07, Justoman wrote:
 I get this with almost all the scripts I run,
 
 It's a whole shit load of undefined variables! what are these and please,
 how can they be fixed?
 
 Here's what I'm talkin bout,
 http://www.darkwatchclan.com/battlestats/bfserverinfo.php
 
 -Justoman
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Fw: [PHP] Undefined variables?

2002-10-10 Thread Kevin Stone

Not to be rude.. but you have got to be kidding.  :-\

There's no way for anybody to tell what's going on without seeing the code.
One way or another the script isn't being given the information it is
expecting.  My guess is that the programmer isn't doing any checking within
the script.  He's assuming that these values are set but when they're not it
spews this list of errors.

Is this a script that you wrote or are you here on behalf of the programmer?

-Kevin

- Original Message -
From: Justoman [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, October 10, 2002 2:07 PM
Subject: [PHP] Undefined variables?


 I get this with almost all the scripts I run,

 It's a whole shit load of undefined variables! what are these and please,
 how can they be fixed?

 Here's what I'm talkin bout,
 http://www.darkwatchclan.com/battlestats/bfserverinfo.php

 -Justoman



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables?

2002-10-10 Thread Justoman


Thanks for the feedback,
I've never actually posted here, so Kevin, cut me some slack.

Here's whats up,
The script I'm trying to run is called Battlestats
It's set up on at: http://www.darkwatchclan.com/battlestats/bfserverinfo.php
(That's where I'm trying to get it to work)

Now, the exact same unedited scipt has been set up on,
http://jk2.gamersimpact.com/bf1942/bfserverinfo.php and runs perfectly.

The source for it, could be found with this link:
http://jk2.gamersimpact.com/download.php?op=getitlid=3

So really, its not so much a programmer error, it just has something to do
with either an error concerning OS working with script, or something wrong
with the PHP that's set up on the server, because this isn't the only
working script that doesn't parse properly on this server. All the errors I
get are undefined variables.

-Justin Justoman Antolini



Kevin Stone [EMAIL PROTECTED] wrote in message
005701c2709c$b651d2e0$6501a8c0@kevin">news:005701c2709c$b651d2e0$6501a8c0@kevin...
 Not to be rude.. but you have got to be kidding.  :-\

 There's no way for anybody to tell what's going on without seeing the
code.
 One way or another the script isn't being given the information it is
 expecting.  My guess is that the programmer isn't doing any checking
within
 the script.  He's assuming that these values are set but when they're not
it
 spews this list of errors.

 Is this a script that you wrote or are you here on behalf of the
programmer?

 -Kevin

 - Original Message -
 From: Justoman [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Thursday, October 10, 2002 2:07 PM
 Subject: [PHP] Undefined variables?


  I get this with almost all the scripts I run,
 
  It's a whole shit load of undefined variables! what are these and
please,
  how can they be fixed?
 
  Here's what I'm talkin bout,
  http://www.darkwatchclan.com/battlestats/bfserverinfo.php
 
  -Justoman
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables?

2002-10-10 Thread Marco Tabini

I think the problem is simply that the other server had a different
configuration setting for error reporting, since I can't find
$debug_wintrmte configured anywhere.

I don't know what this code is for, so it's difficult for me to say how
to fix it, since any changes I make may affect the outcome in a way that
will cause the system to stop working properly.

The only suggestion is to contact the original author or (if you are the
original author) to figure out how those variables should be managed. As
a last resort, and only if you are satisfied with the way the site works
right now (aside from the errors, of course), as James Hicks was
suggesting, you can just hide the errors by typing 

error_reporting(0); 

on the second line of the file, right after the ?

Hope this helps

On Thu, 2002-10-10 at 16:56, Justoman wrote:
 
 Thanks for the feedback,
 I've never actually posted here, so Kevin, cut me some slack.
 
 Here's whats up,
 The script I'm trying to run is called Battlestats
 It's set up on at: http://www.darkwatchclan.com/battlestats/bfserverinfo.php
 (That's where I'm trying to get it to work)
 
 Now, the exact same unedited scipt has been set up on,
 http://jk2.gamersimpact.com/bf1942/bfserverinfo.php and runs perfectly.
 
 The source for it, could be found with this link:
 http://jk2.gamersimpact.com/download.php?op=getitlid=3
 
 So really, its not so much a programmer error, it just has something to do
 with either an error concerning OS working with script, or something wrong
 with the PHP that's set up on the server, because this isn't the only
 working script that doesn't parse properly on this server. All the errors I
 get are undefined variables.
 
 -Justin Justoman Antolini
 
 
 
 Kevin Stone [EMAIL PROTECTED] wrote in message
 005701c2709c$b651d2e0$6501a8c0@kevin">news:005701c2709c$b651d2e0$6501a8c0@kevin...
  Not to be rude.. but you have got to be kidding.  :-\
 
  There's no way for anybody to tell what's going on without seeing the
 code.
  One way or another the script isn't being given the information it is
  expecting.  My guess is that the programmer isn't doing any checking
 within
  the script.  He's assuming that these values are set but when they're not
 it
  spews this list of errors.
 
  Is this a script that you wrote or are you here on behalf of the
 programmer?
 
  -Kevin
 
  - Original Message -
  From: Justoman [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Thursday, October 10, 2002 2:07 PM
  Subject: [PHP] Undefined variables?
 
 
   I get this with almost all the scripts I run,
  
   It's a whole shit load of undefined variables! what are these and
 please,
   how can they be fixed?
  
   Here's what I'm talkin bout,
   http://www.darkwatchclan.com/battlestats/bfserverinfo.php
  
   -Justoman
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
 
 
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables

2002-05-31 Thread Philip Olson


Another similar way, using an array (very simple to 
add tasks):

  $tasks = array('ShowVersion','GetData','CreateImage');

  if (@in_array($_REQUEST['Task'], $tasks)) {
  // add some error checking here (function_exists())
  $$Task();
  } else {
  // maybe run a default task here
  print unknown task;
  }

Am using @ in case 'Task' doesn't exist at all, so no 
error will be seen (undefined variables create E_NOTICE 
level errors).  Although you may want to check this before 
Task even reaches in_array(), with empty().  See also:

  http://www.php.net/error_reporting

$$Task() is a variable function:

  http://uk.php.net/manual/functions.variable-functions.php

And $_REQUEST is a PHP predefined/reserved variable that 
contains a mix of Get, Post and Cookie data.  This may or 
may not be appropriate here:
 
  http://au.phpz.net/manual/language.variables.predefined.php

On a sidenote (picky), consider making variables all 
lowercase. Also when printing a single var, no need to 
surround it with quotes.  print $foo.

Regards,
Philip Olson

On Fri, 31 May 2002, Christopher J. Crane wrote:

 I like this piece of code. In fact, I convert all my scripts that use the
 older If/Else  code. What would happen if the break;  wasn't used. Would
 it just continue through the rest of the function to find another match???
 
 Miguel Cruz [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  On Thu, 30 May 2002, Crane, Christopher wrote:
   if ($Task == ShowVersion) { function ShowVersion(); }
   elseif ($Task == GetData) { function GetData(); print $DataOutput; }
   elseif ($Task == CreateImage) { function CreateImage(); }
   else { print Incorrect Variable or no Variable Suppliesbr; }
 
  if (isset($Task))
  {
switch($Task)
{
case 'ShowVersion':
  ShowVersion();
  break;
case 'GetData':
  GetData;
  print $DataOutput;
  break;
case 'CreateImage':
  CreateImage();
  break;
default:
  print 'Unknown function';
}
  } else {
print 'No function supplied';
  }
 
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Undefined variables

2002-05-31 Thread Darren Gamble

Good day,

I don't have a piece of code off the top of my head, but you'll get lots of
results and examples if you enter those variables into www.php.net 's search
field and search the online documentation (which is very, very good, I
should add).

Hope that helps.


Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948


 -Original Message-
 From: Christopher J. Crane [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 30, 2002 8:06 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] Undefined variables
 
 
 Darren,
 Thanks for the tip on direction to head in. Could you provide 
 an example of
 what you are referring to?
 
 
 Darren Gamble [EMAIL PROTECTED] wrote in message
 078EC26E265CD411BD9100508BDFFC860ED3E64E@shawmail02">news:078EC26E265CD411BD9100508BDFFC860ED3E64E@shawmail02...
  Good day,
 
  Just to clarify, Perl will, in fact, complain if you have undefined
  variables (or variables that you use once) if you have 
 warnings and/or
  strict mode in effect.  Using at least one is strongly recommended.
 
  In PHP, the method you're using for getting form data is 
 deprecated.  You
  should use $HTTP_POST_VARS or $_POST, depending on your 
 version.  Check
 the
  docco for more info on those.
 
  If you really have to check variables using this method, 
 use isset() to
 see
  if the variables ... have been set. =)
 
  
  Darren Gamble
  Planner, Regional Services
  Shaw Cablesystems GP
  630 - 3rd Avenue SW
  Calgary, Alberta, Canada
  T2P 4L4
  (403) 781-4948
 
 
   -Original Message-
   From: Crane, Christopher [mailto:[EMAIL PROTECTED]]
   Sent: Thursday, May 30, 2002 3:07 PM
   To: '[EMAIL PROTECTED]'
   Subject: [PHP] Undefined variables
  
  
   I have an annoying problem, that I know is my own ignorance
   to PHP. I came
   from PERL and this was not a problem there but is with PHP.
  
   Here's the issue.
   I have a number of scripts that use a index.php?Task='some
   sort of task
   name', for example, http://www.foo.com/index.php?Task=ShowVersion
   http://www.foo.com/index.php?Task=ShowVersion .  Then I use
   an if/else
   statement to tell the script what to do if it sees the
   ShowVersion variable.
   In the ShowVersion example, I would call a function that 
 displays the
   version information I defined in the script. As a back up, I
   always provide
   an else statement to catch variables I have no functions for.
  
   If I have a ShowVersion function, GetData function and a 
 CreateImage
   function and the Task variable is empty or a variable that
   does not exists
   comes in like http://www.foo.com/index.php?Task=SomethingDumb
   http://www.foo.com/index.php?Task=SomethingDumb  it 
 would go to the
   default function of something by using the ELSE part of 
 the if/else
   statements.
  
   I hope I am describing this correctly.now here is the
   problem. If I have
   warnings turned on, or if I have a log written for warnings,
   the log fills
   up if someone goes to http://www.foo.com/index.php
   http://www.foo.com/index.php  or http://www.foo.com
  http://www.foo.com
  will error messages like undefine variable TASK on line 
 255. I understand
  the reason, that PHP was expecting the variable Task when 
 it got to the
  if/else statements. So I put in something like if(!($Task)) 
 { function
  Something(); } but it still is looking for the variable so it still
 errors.
 
  In Perl, it would simply be ignored. What do I do here.
 
  Here is a simple example of the code.
 
  if ($Task == ShowVersion) { function ShowVersion(); }
  elseif ($Task == GetData) { function GetData(); print 
 $DataOutput; }
  elseif ($Task == CreateImage) { function CreateImage(); }
  else { print Incorrect Variable or no Variable Suppliesbr; }
 
 
 
 
 
  Christopher J. Crane
  Network Operations Manager
 
  IKON Office Solutions
  860.659.6464
 
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Undefined variables

2002-05-30 Thread Crane, Christopher

I have an annoying problem, that I know is my own ignorance to PHP. I came
from PERL and this was not a problem there but is with PHP.
 
Here's the issue.
I have a number of scripts that use a index.php?Task='some sort of task
name', for example, http://www.foo.com/index.php?Task=ShowVersion
http://www.foo.com/index.php?Task=ShowVersion .  Then I use an if/else
statement to tell the script what to do if it sees the ShowVersion variable.
In the ShowVersion example, I would call a function that displays the
version information I defined in the script. As a back up, I always provide
an else statement to catch variables I have no functions for.
 
If I have a ShowVersion function, GetData function and a CreateImage
function and the Task variable is empty or a variable that does not exists
comes in like http://www.foo.com/index.php?Task=SomethingDumb
http://www.foo.com/index.php?Task=SomethingDumb  it would go to the
default function of something by using the ELSE part of the if/else
statements. 
 
I hope I am describing this correctly.now here is the problem. If I have
warnings turned on, or if I have a log written for warnings, the log fills
up if someone goes to http://www.foo.com/index.php
http://www.foo.com/index.php  or http://www.foo.com http://www.foo.com
will error messages like undefine variable TASK on line 255. I understand
the reason, that PHP was expecting the variable Task when it got to the
if/else statements. So I put in something like if(!($Task)) { function
Something(); } but it still is looking for the variable so it still errors.
 
In Perl, it would simply be ignored. What do I do here.
 
Here is a simple example of the code.
 
if ($Task == ShowVersion) { function ShowVersion(); }
elseif ($Task == GetData) { function GetData(); print $DataOutput; }
elseif ($Task == CreateImage) { function CreateImage(); }
else { print Incorrect Variable or no Variable Suppliesbr; }
 
 
 
 

Christopher J. Crane
Network Operations Manager

IKON Office Solutions
860.659.6464

 



RE: [PHP] Undefined variables

2002-05-30 Thread Leotta, Natalie (NCI/IMS)

You could try using isset first.  I'm not sure where your log is, but if you
check to see if task is set, then maybe that will eliminate the problem :-)

-Natalie

http://www.php.net/manual/en/function.isset.php

-Original Message-
From: Crane, Christopher [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, May 30, 2002 5:07 PM
To: '[EMAIL PROTECTED]'
Subject: [PHP] Undefined variables


I have an annoying problem, that I know is my own ignorance to PHP. I came
from PERL and this was not a problem there but is with PHP.
 
Here's the issue.
I have a number of scripts that use a index.php?Task='some sort of task
name', for example, http://www.foo.com/index.php?Task=ShowVersion
http://www.foo.com/index.php?Task=ShowVersion .  Then I use an if/else
statement to tell the script what to do if it sees the ShowVersion variable.
In the ShowVersion example, I would call a function that displays the
version information I defined in the script. As a back up, I always provide
an else statement to catch variables I have no functions for.
 
If I have a ShowVersion function, GetData function and a CreateImage
function and the Task variable is empty or a variable that does not exists
comes in like http://www.foo.com/index.php?Task=SomethingDumb
http://www.foo.com/index.php?Task=SomethingDumb  it would go to the
default function of something by using the ELSE part of the if/else
statements. 
 
I hope I am describing this correctly.now here is the problem. If I have
warnings turned on, or if I have a log written for warnings, the log fills
up if someone goes to http://www.foo.com/index.php
http://www.foo.com/index.php  or http://www.foo.com http://www.foo.com
will error messages like undefine variable TASK on line 255. I understand
the reason, that PHP was expecting the variable Task when it got to the
if/else statements. So I put in something like if(!($Task)) { function
Something(); } but it still is looking for the variable so it still errors.
 
In Perl, it would simply be ignored. What do I do here.
 
Here is a simple example of the code.
 
if ($Task == ShowVersion) { function ShowVersion(); }
elseif ($Task == GetData) { function GetData(); print $DataOutput; }
elseif ($Task == CreateImage) { function CreateImage(); } else { print
Incorrect Variable or no Variable Suppliesbr; }
 
 
 
 

Christopher J. Crane
Network Operations Manager

IKON Office Solutions
860.659.6464

 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Undefined variables

2002-05-30 Thread Darren Gamble

Good day,

Just to clarify, Perl will, in fact, complain if you have undefined
variables (or variables that you use once) if you have warnings and/or
strict mode in effect.  Using at least one is strongly recommended.

In PHP, the method you're using for getting form data is deprecated.  You
should use $HTTP_POST_VARS or $_POST, depending on your version.  Check the
docco for more info on those.

If you really have to check variables using this method, use isset() to see
if the variables ... have been set. =)


Darren Gamble
Planner, Regional Services
Shaw Cablesystems GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948


 -Original Message-
 From: Crane, Christopher [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 30, 2002 3:07 PM
 To: '[EMAIL PROTECTED]'
 Subject: [PHP] Undefined variables
 
 
 I have an annoying problem, that I know is my own ignorance 
 to PHP. I came
 from PERL and this was not a problem there but is with PHP.
  
 Here's the issue.
 I have a number of scripts that use a index.php?Task='some 
 sort of task
 name', for example, http://www.foo.com/index.php?Task=ShowVersion
 http://www.foo.com/index.php?Task=ShowVersion .  Then I use 
 an if/else
 statement to tell the script what to do if it sees the 
 ShowVersion variable.
 In the ShowVersion example, I would call a function that displays the
 version information I defined in the script. As a back up, I 
 always provide
 an else statement to catch variables I have no functions for.
  
 If I have a ShowVersion function, GetData function and a CreateImage
 function and the Task variable is empty or a variable that 
 does not exists
 comes in like http://www.foo.com/index.php?Task=SomethingDumb
 http://www.foo.com/index.php?Task=SomethingDumb  it would go to the
 default function of something by using the ELSE part of the if/else
 statements. 
  
 I hope I am describing this correctly.now here is the 
 problem. If I have
 warnings turned on, or if I have a log written for warnings, 
 the log fills
 up if someone goes to http://www.foo.com/index.php
 http://www.foo.com/index.php  or http://www.foo.com 
http://www.foo.com
will error messages like undefine variable TASK on line 255. I understand
the reason, that PHP was expecting the variable Task when it got to the
if/else statements. So I put in something like if(!($Task)) { function
Something(); } but it still is looking for the variable so it still errors.
 
In Perl, it would simply be ignored. What do I do here.
 
Here is a simple example of the code.
 
if ($Task == ShowVersion) { function ShowVersion(); }
elseif ($Task == GetData) { function GetData(); print $DataOutput; }
elseif ($Task == CreateImage) { function CreateImage(); }
else { print Incorrect Variable or no Variable Suppliesbr; }
 
 
 
 

Christopher J. Crane
Network Operations Manager

IKON Office Solutions
860.659.6464

 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables

2002-05-30 Thread Christopher J. Crane

Darren,
Thanks for the tip on direction to head in. Could you provide an example of
what you are referring to?


Darren Gamble [EMAIL PROTECTED] wrote in message
078EC26E265CD411BD9100508BDFFC860ED3E64E@shawmail02">news:078EC26E265CD411BD9100508BDFFC860ED3E64E@shawmail02...
 Good day,

 Just to clarify, Perl will, in fact, complain if you have undefined
 variables (or variables that you use once) if you have warnings and/or
 strict mode in effect.  Using at least one is strongly recommended.

 In PHP, the method you're using for getting form data is deprecated.  You
 should use $HTTP_POST_VARS or $_POST, depending on your version.  Check
the
 docco for more info on those.

 If you really have to check variables using this method, use isset() to
see
 if the variables ... have been set. =)

 
 Darren Gamble
 Planner, Regional Services
 Shaw Cablesystems GP
 630 - 3rd Avenue SW
 Calgary, Alberta, Canada
 T2P 4L4
 (403) 781-4948


  -Original Message-
  From: Crane, Christopher [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, May 30, 2002 3:07 PM
  To: '[EMAIL PROTECTED]'
  Subject: [PHP] Undefined variables
 
 
  I have an annoying problem, that I know is my own ignorance
  to PHP. I came
  from PERL and this was not a problem there but is with PHP.
 
  Here's the issue.
  I have a number of scripts that use a index.php?Task='some
  sort of task
  name', for example, http://www.foo.com/index.php?Task=ShowVersion
  http://www.foo.com/index.php?Task=ShowVersion .  Then I use
  an if/else
  statement to tell the script what to do if it sees the
  ShowVersion variable.
  In the ShowVersion example, I would call a function that displays the
  version information I defined in the script. As a back up, I
  always provide
  an else statement to catch variables I have no functions for.
 
  If I have a ShowVersion function, GetData function and a CreateImage
  function and the Task variable is empty or a variable that
  does not exists
  comes in like http://www.foo.com/index.php?Task=SomethingDumb
  http://www.foo.com/index.php?Task=SomethingDumb  it would go to the
  default function of something by using the ELSE part of the if/else
  statements.
 
  I hope I am describing this correctly.now here is the
  problem. If I have
  warnings turned on, or if I have a log written for warnings,
  the log fills
  up if someone goes to http://www.foo.com/index.php
  http://www.foo.com/index.php  or http://www.foo.com
 http://www.foo.com
 will error messages like undefine variable TASK on line 255. I understand
 the reason, that PHP was expecting the variable Task when it got to the
 if/else statements. So I put in something like if(!($Task)) { function
 Something(); } but it still is looking for the variable so it still
errors.

 In Perl, it would simply be ignored. What do I do here.

 Here is a simple example of the code.

 if ($Task == ShowVersion) { function ShowVersion(); }
 elseif ($Task == GetData) { function GetData(); print $DataOutput; }
 elseif ($Task == CreateImage) { function CreateImage(); }
 else { print Incorrect Variable or no Variable Suppliesbr; }





 Christopher J. Crane
 Network Operations Manager

 IKON Office Solutions
 860.659.6464





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables

2002-05-30 Thread Miguel Cruz

On Thu, 30 May 2002, Crane, Christopher wrote:
 if ($Task == ShowVersion) { function ShowVersion(); }
 elseif ($Task == GetData) { function GetData(); print $DataOutput; }
 elseif ($Task == CreateImage) { function CreateImage(); }
 else { print Incorrect Variable or no Variable Suppliesbr; }

if (isset($Task))
{
  switch($Task)
  {
  case 'ShowVersion':
ShowVersion();
break;
  case 'GetData':
GetData;
print $DataOutput;
break;
  case 'CreateImage':
CreateImage();
break;
  default:
print 'Unknown function';
  }
} else {
  print 'No function supplied';
}



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables

2002-05-30 Thread Christopher J. Crane

I like this piece of code. In fact, I convert all my scripts that use the
older If/Else  code. What would happen if the break;  wasn't used. Would
it just continue through the rest of the function to find another match???

Miguel Cruz [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Thu, 30 May 2002, Crane, Christopher wrote:
  if ($Task == ShowVersion) { function ShowVersion(); }
  elseif ($Task == GetData) { function GetData(); print $DataOutput; }
  elseif ($Task == CreateImage) { function CreateImage(); }
  else { print Incorrect Variable or no Variable Suppliesbr; }

 if (isset($Task))
 {
   switch($Task)
   {
   case 'ShowVersion':
 ShowVersion();
 break;
   case 'GetData':
 GetData;
 print $DataOutput;
 break;
   case 'CreateImage':
 CreateImage();
 break;
   default:
 print 'Unknown function';
   }
 } else {
   print 'No function supplied';
 }





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Undefined variables

2002-05-30 Thread Martin Towell

if you want to do the same thing for no task supplied and unknown task
then you could do this:

switch(@$Task)
{
  case 'ShowVersion':
ShowVersion();
break;
  case 'GetData':
GetData;
print $DataOutput;
break;
  case 'CreateImage':
CreateImage();
break;
  default:
print 'Unknown function or No function supplied';
}

basically, suppress warnings

-Original Message-
From: Christopher J. Crane [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 31, 2002 2:33 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Undefined variables


I like this piece of code. In fact, I convert all my scripts that use the
older If/Else  code. What would happen if the break;  wasn't used. Would
it just continue through the rest of the function to find another match???

Miguel Cruz [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Thu, 30 May 2002, Crane, Christopher wrote:
  if ($Task == ShowVersion) { function ShowVersion(); }
  elseif ($Task == GetData) { function GetData(); print $DataOutput; }
  elseif ($Task == CreateImage) { function CreateImage(); }
  else { print Incorrect Variable or no Variable Suppliesbr; }

 if (isset($Task))
 {
   switch($Task)
   {
   case 'ShowVersion':
 ShowVersion();
 break;
   case 'GetData':
 GetData;
 print $DataOutput;
 break;
   case 'CreateImage':
 CreateImage();
 break;
   default:
 print 'Unknown function';
   }
 } else {
   print 'No function supplied';
 }





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Undefined variables

2002-03-30 Thread Ernesto

Hi, newbie here.

I was erroneously using error_reporting=E_ALL ~E_NOTICE on my debug
server.
Now, I changed it to error_reporting=E_ALL and I can see lots of warnings
about using undefined variables.
So, if I don't want to see warnings all over the place, I have to check
every variable with isset() before I use it.
Is it necesary that I do this all the time? Why can't I trust on the
emptiness of uninitialized variables?
I'm using register_globals=Off, so there should be no problem with that.

I know it's a good practice to declare and initialize all variables, but I
need my scripts to run as fast as they can (and I'm too lazy to check every
variable before I use it, too :-)

So... do I have any choice?

Regards,
Ernesto




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables

2002-03-30 Thread Lars Torben Wilson

On Sat, 2002-03-30 at 17:30, Ernesto wrote:
 Hi, newbie here.
 
 I was erroneously using error_reporting=E_ALL ~E_NOTICE on my debug
 server.
 Now, I changed it to error_reporting=E_ALL and I can see lots of warnings
 about using undefined variables.
 So, if I don't want to see warnings all over the place, I have to check
 every variable with isset() before I use it.
 Is it necesary that I do this all the time? Why can't I trust on the
 emptiness of uninitialized variables?
 I'm using register_globals=Off, so there should be no problem with that.
 
 I know it's a good practice to declare and initialize all variables, but I
 need my scripts to run as fast as they can (and I'm too lazy to check every
 variable before I use it, too :-)
 
 So... do I have any choice?
 
 Regards,
 Ernesto

Not really. You either have to init your variables or turn off notices
in error_reporting() (or otherwise suppress them; i.e. display_errors =
off).



-- 
 Torben Wilson [EMAIL PROTECTED]
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables

2002-03-30 Thread Shane Wright

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


 Not really. You either have to init your variables or turn off notices
 in error_reporting() (or otherwise suppress them; i.e. display_errors =
 off).

initialising them with safe defaults is the thing to do - the point of the 
error is to warn about uninitialised variables (which, if register_globals is 
on, could be used by an attacker to make your scripts to bad things...)

- --
Shane
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8pmm85DXg6dCMBrQRAl0PAJ9W6iBFtaYtXBKnvmtfKPPVJzHWyACfRg91
6IXouixJwNAsLJDhvYyhnSs=
=DBej
-END PGP SIGNATURE-


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables

2002-03-30 Thread Lars Torben Wilson

On Sat, 2002-03-30 at 17:43, Shane Wright wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 
  Not really. You either have to init your variables or turn off notices
  in error_reporting() (or otherwise suppress them; i.e. display_errors =
  off).
 
 initialising them with safe defaults is the thing to do - the point of the 
 error is to warn about uninitialised variables (which, if register_globals is 
 on, could be used by an attacker to make your scripts to bad things...)
 
 - --
 Shane

Yes, this is my standard suggestion as well, but since Ernesto seemed
to be aware of the issues I decided not to press the point. 


-- 
 Torben Wilson [EMAIL PROTECTED]
 http://www.thebuttlesschaps.com
 http://www.hybrid17.com
 http://www.inflatableeye.com
 +1.604.709.0506


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Undefined variables

2002-03-30 Thread Shane Wright

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


sorry, didnt get that that was your prefered method - didnt mean to step on 
your toes :)

S

On Sunday 31 March 2002 2:50 am, Lars Torben Wilson wrote:
 On Sat, 2002-03-30 at 17:43, Shane Wright wrote:
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
   Not really. You either have to init your variables or turn off notices
   in error_reporting() (or otherwise suppress them; i.e. display_errors =
   off).
 
  initialising them with safe defaults is the thing to do - the point of
  the error is to warn about uninitialised variables (which, if
  register_globals is on, could be used by an attacker to make your scripts
  to bad things...)
 
  - --
  Shane

 Yes, this is my standard suggestion as well, but since Ernesto seemed
 to be aware of the issues I decided not to press the point.
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8pm4K5DXg6dCMBrQRAsTLAJ9377x/gjRKbHrfcSYW11BKUgotgACfQmTw
x2rcCdMlPbAaPg8zAey7L/8=
=WVbB
-END PGP SIGNATURE-


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Undefined variables

2001-07-04 Thread Uri Even-Chen

To PHP-general group,


I have configured PHP to report all errors  warnings (error_reporting
=   E_ALL on php.ini file), but since then I get tons of warning
messages for Undefined variables. For example, referring $HTTP_HOST
directly leads a message like Undefined variable:  HTTP_HOST in ... on
line  I tried to use $HTTP_SERVER_VARS['HTTP_HOST'] instead, but
then I get the message Undefined index:  HTTP_HOST in ... on line 
How do I get rid of these messages? I also get these messages for
internal variables, cookie variables (globals) etc.


I am also interested in testing whether the user typed the URL properly,
including upper/lower case. I'm using this code to check it in the
beginning of the page:

?php
if (strcmp($HTTP_SERVER_VARS['HTTP_HOST'], 'dating.speedy.co.il') != 0)
{
   header('Location: http://dating.speedy.co.il/');
   exit;
}
?

But, if the user enters http://DATING.SPEEDY.CO.IL/, this has no
effect. Is there any way to get a case sensitive version of HTTP_HOST?
(I noticed HTTP_HOST has changed since the previous version of PHP 
apache).


Thanks,

Uri Even-Chen
Speedy Software
Raanana, Israel.

Welcome to Speedy Net (In Hebrew):
   http://www.speedy.co.il/
Speedy Dating (In Hebrew):
   http://dating.speedy.co.il/
Speedy Composer (In English):
   http://www.speedy.co.il/composer/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Undefined Variables / PHP 4.0.4pl1

2001-05-18 Thread Martin Thoma

Hello !

I just installed PHP 4.0.4pl1 over an existing PHP 4.0.1 on Win98 with
Apache. Alle works greate, but I get a lot of warnings:

Warning: Undefined variable: MyVariable in filename

The warnings weren't there in the earlier version. How can I turn of
these warnings ?

Regards

Martin



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Undefined Variables / PHP 4.0.4pl1

2001-05-18 Thread Johnson, Kirk

If you have access to php.ini, see the Error handling and logging section.
Else, see http://www.php.net/manual/en/ref.errorfunc.php

Kirk

 -Original Message-
 From: Martin Thoma [mailto:[EMAIL PROTECTED]]
 Sent: Friday, May 18, 2001 1:36 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Undefined Variables / PHP 4.0.4pl1
 
 
 Hello !
 
 I just installed PHP 4.0.4pl1 over an existing PHP 4.0.1 on Win98 with
 Apache. Alle works greate, but I get a lot of warnings:
 
 Warning: Undefined variable: MyVariable in filename
 
 The warnings weren't there in the earlier version. How can I turn of
 these warnings ?
 
 Regards
 
 Martin
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: 
 [EMAIL PROTECTED]
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Undefined Variables / PHP 4.0.4pl1

2001-05-18 Thread Martin Thoma

Thanx a lot, I found it in php.ini !

Johnson, Kirk schrieb:

 If you have access to php.ini, see the Error handling and logging section.
 Else, see http://www.php.net/manual/en/ref.errorfunc.php

 Kirk

  -Original Message-
  From: Martin Thoma [mailto:[EMAIL PROTECTED]]
  Sent: Friday, May 18, 2001 1:36 PM
  To: [EMAIL PROTECTED]
  Subject: [PHP] Undefined Variables / PHP 4.0.4pl1
 
 
  Hello !
 
  I just installed PHP 4.0.4pl1 over an existing PHP 4.0.1 on Win98 with
  Apache. Alle works greate, but I get a lot of warnings:
 
  Warning: Undefined variable: MyVariable in filename
 
  The warnings weren't there in the earlier version. How can I turn of
  these warnings ?
 
  Regards
 
  Martin
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail:
  [EMAIL PROTECTED]
 

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]