Re: Yeah I'm sortof a noob

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



TY.  That should help greatly!
"Shawn McKenzie" <nospam@xxxxxxxxxxxxx> wrote in message 
news:F4.44.48736.09C4EE84@xxxxxxxxxxxxxxx
> 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
>
>
> 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux