Re: Undefined index error

From: Date: Mon, 19 Aug 2002 22:48:12 +0000
Subject: Re: Undefined index error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-113270@lists.php.net to get a copy of this message
If you try to access a form variable that hasn't been set, you get an undefined index. Try checking with something like if(isset($_POST['SortBy'])) { // do something with 'SortBy' } In any case, you'll get the undefined index warning anytime you try to read an array index that hasn't been set. ..michael.. On Mon, 2002-08-19 at 14:49, Shu Chow wrote: > I'm using the superglobal $_POST array to access URL > parameters passed to my page. I was getting undefined > constant errors in my error_log file, and found that I > needed to quote the variables in the array. > $_POST['SortBy'] etc. Now, it appears that I've just > traded the undefined constant errors for undefined index > warnings. Everytime a page hits a page with url > parameters, it triggers a warning in the error_log file. > What's triggering these undefined index errors? I suppose > I could lower the logging level in php.ini, but I'd rather > code properly than to hide the problem. Thanks!

« previous php.general (#113270) next »