It used to work and now it doesn't

Problems with the Windows version of XAMPP, questions, comments, and anything related.

It used to work and now it doesn't

Postby FishMA » 25. January 2010 22:54

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?
FishMA
 
Posts: 5
Joined: 17. December 2009 04:27

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

Postby Wiedmann » 25. January 2010 23:38

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)
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

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

Postby FishMA » 26. January 2010 00:28

Thanks for the reply. On your second comment, should

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


simply be?

Code: Select all
 $_POST['boc'], "double",
FishMA
 
Posts: 5
Joined: 17. December 2009 04:27

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

Postby Wiedmann » 26. January 2010 07:58

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); 
Wiedmann
AF Moderator
 
Posts: 17106
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

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

Postby FishMA » 26. January 2010 19:12

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
FishMA
 
Posts: 5
Joined: 17. December 2009 04:27


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 40 guests