Jeff wrote:
I'm still coming to grips with Notices, particularly on missing indexes.
Lets say we have a form full of check boxes. An unchecked checkbox is
not sent in $_REQUEST and if you do something with
$_REQUEST['my_checkbox'] you'll get a notice. Is there a clean method of
dealing with this?
I'm a recovering perl programmer so conciseness is still important. I
suppose I'll get over it eventually but I still miss ||= .
Jeff
You should NEVER configure a development server to ignore notices. Each
one is a potential bug in your program - which is why they are being
displayed. They are notices to let you know there MAY be a problem. A
good programmer will fix these notices.
And it's easy to do. Just use isset() to determine of the checkbox is
set, or not, i.e.
$my_checkbox = isset($_POST['my_checkbox']) ? $_POST['my_checkbox'] : '';
The last value can be an empty string, null, 0 or whatever you want for
a value when the checkbox is not set.
Also, you should always user $_POST or $_GET instead of $_REQUEST.
$_REQUEST gets its data from $_GET, $_POST or $_COOKIE, and can too
easily cause problems (i.e. what happens if two years from now,
somewhere else in your program, you call setcookie('my_checkbox', 1)?
This code could break, among other things.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================