"Gilles Girard" <gg*****@blowupgalerie.com> wrote in message
news:2004081117093680432%ggirard@blowupgaleriecom. ..
Hi,
I use a sample code showed in php.net website manual with my
conditions, and the result is always true.
<?php if ( $username="myusername" AND $password="mypassword" ) { ?>
True
<?php } else { ?>
False
<?php } ?>
Where's the bug?
Thanks in advance
Gilles Girard
The PHP equals (=) operator assigns variables. So, when your first line is
this...
<?php if ( $username="myusername" AND $password="mypassword" ) { ?>
.... you are assigning $username the value "myusername" and $password the
value "mypassword". In PHP, any string that does not equal "" or "0" is
considered to be true. You must use the comparison operator (==) instead to
compare the two variables to their respective strings. So your first line
should be changed to this:
<?php if ( $username=="myusername" AND $password=="mypassword" ) { ?>