Re: [PHP] Undefined Index - is this how you "declare" get & post?

2003-10-29 Thread John W. Holmes
Terence wrote:

Since I started using error_reporting(E_ALL), I havent found (in my opinion)
a good way to declare GET and POST variables when getting them from a form
or querystring. I have searched google and the docs for several hours now
without much luck.

if ($HTTP_GET_VARS["i"] == "") {
 include("myfile.php");
}
?>
Is there a better way?
I have tried var $i (only for classes I've discovered)
settype($i, "integer")
Thanks in advance.

isset() is your friend.

if(isset($HTTP_GET_VARS['i']) && $HTTP_GET_VARS['i'] == '')
{ include('myfile.php'); }
This will not trigger any warning, even under E_ALL.

In response to some of the other posts, developing at E_ALL is a good 
idea as it'll help you spot potential problem areas.

Also, even though you have a form element defined, it may not always 
appear in $HTTP_GET_VARS/$_GET (post, etc). One example are checkboxes. 
If no boxes are checked, the variable is never created and this is the 
way to check.

--
---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] Undefined Index - is this how you "declare" get & post?

2003-10-29 Thread Terence

- Original Message - 
From: "Chris W. Parker" <[EMAIL PROTECTED]>


> Terence 
> on Wednesday, October 29, 2003 4:40 PM said:
>
> > Since I started using error_reporting(E_ALL), I havent found (in my
> > opinion) a good way to declare GET and POST variables when getting
> > them from a form or querystring. I have searched google and the docs
> > for several hours now without much luck.
>
> Why would you want to declare a GET or POST variable in the first place?
> You'd be overwriting whatever value was stored from the form.

error_reporting(E_ALL) tells me that I have an indefined index, but as Jon
Kriek pointed out,
perhaps reporting "all" the errors is not such a "good thing".

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



RE: [PHP] Undefined Index - is this how you "declare" get & post?

2003-10-29 Thread Chris W. Parker
Terence 
on Wednesday, October 29, 2003 4:40 PM said:

> Since I started using error_reporting(E_ALL), I havent found (in my
> opinion) a good way to declare GET and POST variables when getting
> them from a form or querystring. I have searched google and the docs
> for several hours now without much luck.

Why would you want to declare a GET or POST variable in the first place?
You'd be overwriting whatever value was stored from the form.

Also, depending on your version of PHP you should be using $_GET and
$_POST and not $HTTP_GET_VARS or $HTTP_POST_VARS.


hth,
Chris.
--
Don't like reformatting your Outlook replies? Now there's relief!
http://home.in.tum.de/~jain/software/outlook-quotefix/

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



[PHP] Undefined Index - is this how you "declare" get & post?

2003-10-29 Thread Terence
Hi List,

Since I started using error_reporting(E_ALL), I havent found (in my opinion)
a good way to declare GET and POST variables when getting them from a form
or querystring. I have searched google and the docs for several hours now
without much luck.



Is there a better way?
I have tried var $i (only for classes I've discovered)
settype($i, "integer")

Thanks in advance.

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