Warning: number_format() expects parameter 1 to be double, string given in /home/....

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 26, 2014   (RSS)

By andybarn - September 24, 2014

Hi

I am getting the following error on my “price” field that I am trying to display.

Warning: number_format() expects parameter 1 to be double, string given in /home/...

My syntax is:-

<?php echo number_format($listing['price']) ?>

Now this same php file works fine on my dedicated server running php ver 5.3.23  but not on my reseller server running php ver 5.4.30 so may be a php version issue?

Should I be writing the above syntax a different way, if so could you tell me how.

Thanks for your help.

Andy

By andybarn - September 25, 2014

UPDATE

I have discovered that this problem only occurs if the price field is "blank". If I change the price field to "0" the error code disappears.

Andy

By andybarn - September 26, 2014

Hi Claire

Thanks for your reply.

You are absolutely correct - the problem only occurred when the price field was blank.

I discovered this after trying several things and was going to update the forum with my findings but you beat me to it :-)

Thanks for your help and input  Claire

Kind regards

Andy