Archive for February, 2007

Not a Number is a number

I was having some trouble in PHP with a variable getting sent as NaN.
Try this out:

  1. <?
  2. echo " Is NaN a number: " . is_numeric(NAN);
  3. ?>

This is what I was doing in my PHP code:

  1. <?
  2. if ($homePhotoID== || !is_numeric($homePhotoID) ){
  3. $homePhotoID=‘NULL’;
  4. }
  5. ?>

I was using this variable to insert into a MySQL query. Debugging I figured out it was sending through: NaN
This is how my code ended up:

  1. <?
  2. if ($homePhotoID== || !is_numeric($homePhotoID) || is_nan($homePhotoID) ){
  3. $homePhotoID=‘NULL’;
  4. }
  5. ?>

2 comments February 8th, 2007


Calendar

February 2007
M T W T F S S
« Jan   Mar »
 1234
567891011
12131415161718
19202122232425
262728  

Posts by Month

Posts by Category