On Thu, Nov 13, 2003 at 04:04:16AM -0500, Jake McHenry wrote:
:
: print_r($_POST) shows me that $_POST has the single 0 value. I solved
: my problem, instead of having just if ($_POST['test']), I changed it
: to if ($_POST['test'] != ""). Right after I posted, I tried this, and
: a couple other things.. The problem only happens when I don't have any
: conditions within the ().
That's due to PHP's automatic type conversion. In other words, certain
string values can get evaluated to either a boolean TRUE or FALSE. So
you have to do explicit tests.
For example, what does this code snippet do?
if ($_POST['test'])
{
do_right();
}
else
{
do_wrong();
}
If $_POST['test'] has an empty string, it calls do_wrong().
If $_POST['test'] has the string "0", it still calls do_wrong().
http://www.php.net/manual/en/language.types.boolean.php#language.types.boolean.casting
Your move to change your if-statement is a good start to doing the right
thing. The next step is to scrub your $_POST data and make sure that it
is valid.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php