Log in

View Full Version : Question about condition


AnhTuanCool
10-11-2004, 01:19 PM
Hi,

I have a question, is it OR '' still count as an condition or PHP just cross out that OR ''?

Colin F
10-11-2004, 01:22 PM
I don't understand your question...

You can use "OR TRUE" or something similiar, but that would defeat the purpose of the if clause.
You can also say if($var == ('foo' OR ''){

AnhTuanCool
10-11-2004, 01:49 PM
I use ... OR iif($expression, $valuereturniftrue, $valuereturniffalse = '') then if my $expression is false then I will get OR '' right?

Is that iif function always use to condition an expression in a comparison like $var = iif(....) or we can use it as a single condition like iif($expression, then true, then false) ?

Colin F
10-11-2004, 01:59 PM
you can leave away the $valuereturniffalse

Are you trying to do this in a MYSQL query?

filburt1
10-11-2004, 02:06 PM
What is the exact condition you are trying to evaluate?

AnhTuanCool
10-11-2004, 02:33 PM
In the hack that I made

if (
$bbuserinfo['password'] != iif($password AND !$md5password, md5(md5($password) . $bbuserinfo['salt']), '') AND
$bbuserinfo['password'] != md5($md5password . $bbuserinfo['salt']) AND
$bbuserinfo['password'] != iif($md5password_utf, md5($md5password_utf . $bbuserinfo['salt']), '') OR
$bbuserinfo['secpassword'] != iif($password2 != '', md5(md5($password2)), '')
)


Look at the last line with OR as begin.

filburt1
10-11-2004, 03:22 PM
That's too complex to even read. I suggest breaking some parts of it into functions (for example, password_matches_md5_hash()) and then ditching iif. An inline if is not pretty to begin with, and it is a mess to deal with inside a normal if.

AnhTuanCool
10-11-2004, 03:43 PM
An inline if is not pretty to begin with, and it is a mess to deal with inside a normal if.
Yah, I saw that too :ermm:, I'll try to break it into functions, thanks for the tip filburt1 :)