You are here: Re: Help needed with is_null « PHP Programming Language « IT news, forums, messages
Re: Help needed with is_null

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация