That practice $_POST[formReviewBy] should be discouraged.  That kind
of practice is nearly as bad as magic numbers.

You *should* always put variables referenced by $_POST["formReviewBy"]
in quotes unless specifically designed.

Why??

If you run into a page with a mysterious error (usually missing data),
one strategy is to turn on all the debug output using

error_reporting(E_ALL)

to see if there are any clues about why your code isn't working.  I
tried this on a typical page, and here's what I got:

Notice: Use of undefined constant category_id - assumed 'category_id' in
/usr/home/devweb/madi/mods/autoresponder/src/index.php on line 24

and in this index.php on line 24:

24: $arr_list[category_id] = $db_cat_id;

I apologize if I am ranting, but I've spent time attempting to debug other
programmer's code when they're guilty of this.


-----Original Message-----
From: Justin French [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 18, 2003 8:57 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] $_POST[]


On Friday, December 19, 2003, at 01:35  PM, Philip J. Newman wrote:

> <?php if ($_POST[formReviewBy]=="Cade Lloyd") { echo "selected"; } ?>
>
> Should $_POST[formReviewBy] have quotes or dose it not matter?

Well, since you've obviously tested it and it works, then the simple
answer is probably "it doesn't matter", however, all examples in the
manual using string-keys that I can see
(http://www.php.net/manual/en/language.types.array.php) use quote
around the key.

You will DEFINITELY need them when the string key has a space or
possibly other not-allowed characters, so my advice (which I follow
myself) is to always include quotes around a string key.

$_POST['formReviewBy']=='Cade Lloyd') { echo 'selected'; }

No need for double quotes unless PHP needs to evaluate $vars or escaped
chars (like \n or \t) either.


Justin French

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

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

Reply via email to