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)
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
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 claire - September 25, 2014
Hi Andy
If you're still having problems with this, then I suggest checking if the price is blank before trying to output it. It'd be the fastest way to fix the problem without having to update any database fields.
Claire Ryan
interactivetools.com
Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
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