Posted by Colin McKinnon on 05/27/05 00:22
Brian spilled the following:
> Hi all
>
> whats wrong with this?
>
> if ( (strtolower($myrow[status]) != 'n') || (strtolower($myrow[status]) !=
> 'u') ) {
> .......
> }
>
> I'm trying to say if $myrow[status]) if not 'n' or 'u' then do X but it's
> just not
> playing ball here? I have tried putting in brackets, taking them out,
> moving them about and all sorts, just can't get it to work
>
For starters, the line is too long and unnecessarily re-evaluating the
function.
It's doing exactly what you tell it - you have a semantic error in your
program. Try making it a bit simpler and it might be clearer:
$ch = strtolower($myrow[status]);
if ( ($ch!='n') || ($ch!='u') ) { ...
At least one of the two expressions will always be true (since $ch cannot be
'u' and 'n' at the same time)
I suspect you really mean not 'n' *AND* not 'u'
HTH
C.
[Back to original message]
|