Page 1 of 1

It used to work and now it doesn't

PostPosted: 25. January 2010 22:54
by FishMA
I have been working a website for several months. I use Dreamweaver 8 for layout and some boiler plate coding. I recently upgraded from xampp 1.6.8 to 1.7.3. This morning I returned to modify a page that I have first put together months ago. The page had worked fine in xampp and still works fine on my server. However, wtihout making any changes to it, I now receive this error message:

Warning: number_format() expects parameter 1 to be double, string given in C:\xampp\htdocs\ifq_css\deliveries_css.php on line 267


The page contains several boxes to enter data. If data is entered then there is no error message. If there is no data entered, the field is blank, I receive a similar message for each blank field.

This is line 267:

Code: Select all
$boc2 = number_format($boc)


And the value of $boc comes form the form with the following code:

Code: Select all
 GetSQLValueString($_POST['boc'], "double"),


Has something changed in xampp, mysql, or something else that I am unaware of, or can someone please help me understand how to resolve this issue?

Re: It used to work and now it doesn't

PostPosted: 25. January 2010 23:38
by Wiedmann
Code: Select all
$boc2 = number_format($boc);

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

You can change this to:
Code: Select all
$boc2 = number_format((float) $boc);



And the value of $boc comes form the form with the following code:
Code: Select all
GetSQLValueString($_POST['boc'], "double"),

But I don't think you want use GetSQLValueString() in this case, because this function is not returning a real double in any case. Instead it's always returning a string (and number_format want have a real double/float)

Re: It used to work and now it doesn't

PostPosted: 26. January 2010 00:28
by FishMA
Thanks for the reply. On your second comment, should

Code: Select all
GetSQLValueString($_POST['boc'], "double"),


simply be?

Code: Select all
 $_POST['boc'], "double",

Re: It used to work and now it doesn't

PostPosted: 26. January 2010 07:58
by Wiedmann
I mean, don't use the return value from GetSQLValueString as parameter value for number_format. Instead something like:
Code: Select all
$boc2 = number_format(isset($_POST['boc']) ? (float) $_POST['boc'] : 0); 

Re: It used to work and now it doesn't

PostPosted: 26. January 2010 19:12
by FishMA
Wiedmann

Thanks for that clarification. Sometimes I a little slow on the uptake, particularly late at night.
I made the changes and it solve my warning problems.

Pete