Re: Yeah I'm sortof a noob
| From: | Frank Stanovcak | Date: | Fri, 10 Oct 2008 18:40:22 +0000 |
| Subject: | Re: Yeah I'm sortof a noob | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-281708@lists.php.net to get a copy of this message | ||
TY. That should help greatly!
"Shawn McKenzie" <nospam@mckenzies.net> wrote in message
news:F4.44.48736.09C4EE84@pb1.pair.com...
> Frank Stanovcak wrote:
>> I'm trying to follow the three precepts of accepting user entries...
>> 1. never trust it.
>> 2. never trust it.
>> 3. never trust it ever!
>>
>> I have one entry that may equal 0 on submission, and if it does is
>> tripping
>> a bool false result, so I came up with this work around. However when I
>> put
>> this in my code the page fails to load. What did I do wrong, and please
>> be
>> specific. I already know I'm stupid, and to answer the question. The
>> extra
>> ';' are for my clarity to know that is the end of the if or foreach
>> statement. Plus it carried over from java script and keeps me out of
>> trouble as I flip between the two.
>>
>> I am looking for the instance when the key is 'ExtraCases' as that is the
>> field that will possibly be zero on submission.
>>
>> //check to make sure all the entries passed
>> foreach($Filtered as $ThisKey => $ThisVar) {
>> if($ThisVar == FALSE) {
>> if(($ThisKey == 'ExtraCases') and
>> (filter_has_var(INPUT_POST,'ExtraCases'))) {
>> if($_POST['ExtraCases'] == 0) {
>> $noProb = TRUE;
>> } else {
>> $Continue = FALSE;
>> $WrongData[$ThisKey] = TRUE;
>> };
>> } else {
>> $Continue = FALSE;
>> $WrongData[$ThisKey] = TRUE;
>> };
>> };
>> };
>>
>>
>
> Well, I haven't studied your code to see the problem, but I'm replying
> to your "workaround". You should be able to code this without the
> workaround if you use the correct comparison operators.
>
> == is untyped value comparison
> === is a strict comparison (must be same value AND same type, boolean,
> string, int, etc...)
>
> These are correct:
> 0 == false
> '' == false
> null == false
> 69 == true
> 'false' == true
>
> These are not:
> 0 === false
> '' === false
> null === false
> 69 === true
> 'false' === true
>
> -Shawn
>
>
>