Re: Undefined Index Errors
| From: | Marek Kilimajer | Date: | Fri, 06 Feb 2004 16:06:39 +0000 |
| Subject: | Re: Undefined Index Errors | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177023@lists.php.net to get a copy of this message | ||
You can either:
1. put @ in front of each variable, e.g.
$adminID = @$_ENV['HTTP_REMOTE_USER'];
2. change your error reporting level:
error_reporting(E_ALL ^ E_NOTICE);
Cameron B. Prince wrote:
Hey guys, Here's a chunk of code from the top of a multi-function page I converted from Perl to PHP:$userid = $_REQUEST['USERID']; # USERID = selected userid $dlist = $_REQUEST['DLIST']; # DLIST = indicates who to display $action = $_REQUEST['ACTION']; # ACTION = indicates approval ordenial$more = $_REQUEST['MORE']; # MORE = ID of person to showdetails$delete = $_REQUEST['DELETE']; # DELETE = indicates to delete user $ltr = $_REQUEST['LTR']; # LTR = start ltr of last name $modpwd = $_REQUEST['MODPWD']; # MODPWD = indicates modifying pwd $expire = $_REQUEST['EXPIRE']; # EXPIRE = indicates to expire pwd $upduser = $_REQUEST['UPDUSER']; # UPDUSER = indicates user infoupdated$denyuser = $_REQUEST['DENYUSER']; # DENYUSER = indicates user wasdenied$reason = $_REQUEST['REASON']; # REASON = Reason user was denied$adminID = $_ENV['HTTP_REMOTE_USER']; I'm creating some strings from array elements obviously. The issue is, the array elements don't always exist depending on which function you are running. And when they don't, the server log is full of undefined index errors. Is there a way I can avoid these errors without adding a "if(isset(...))" around each one? Thanks, Cameron