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 Supplies<br>"; } 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