Posted by Matt Madrid on 08/04/07 04:39
Big Moxy wrote:
> Would someone be so kind as to tell me what is wrong with this code?
Nothing that I can see...
>
> (1) This code block indicates the session variable nomex is null.
> if (is_null($_SESSION['nomex'])){
> echo " is null.";
> }
> else {
> echo " is not null.";
> }
>
> (2) However on the same page this code block always adds 100 to the
> price.
That can't be true. If the above code said it was NULL, then the
second IF block below can't be executing. Are you sure that there
isn't something in between these two blocks of code. Is this even
your "real" code, or just a quick rewrite.
> if ($_SESSION['nomex'] != "^^no^^"){
> if (!is_null($_SESSION['nomex'])){
> // NOMEX Lining
> $new_price = $new_price + 100;
> }
> }
> echo "$".$new_price;
>
I execute this code:
-------
$new_price = 49;
if (is_null($_SESSION['nomex'])){
echo " is null.";
}
else {
echo " is not null.";
}
if ($_SESSION['nomex'] != "^^no^^"){
if (!is_null($_SESSION['nomex'])){
// NOMEX Lining
$new_price = $new_price + 100;
}
}
echo "$".$new_price;
-------
Output is:
is null.$49
Navigation:
[Reply to this message]
|