0
votes

I have 2 ubuntu servers with MySQL version:

Server 1: MySQL Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using EditLine wrapper

Server 2: MySQL Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using EditLine wrapper

The PHP code is on other server and I just change the IP of connection like this Mysql connect 10.1.1.1 Mysql connect 10.1.1.2

When I connect to MySQL server 10.1.1.1 everything is working and no PHP error messages.

When I connect to mysql server 10.1.1.2 i have this php error:

Command: number_format(trim($order[$i]['value']), 2, ',', '.')

Error: Warning: number_format() expects parameter 1 to be double, string given in /home/admin/web/orders.php on line 45

The server 1 is an old ubuntu installation and server 2 is a new Ubuntu installation.

Server 1 and Server 2 is used only to run MySQL, PHP codes are coming from other servers.

I just did the database backup from server 1 and have restored this backup on server 2.

I tried to see some my.cnf configs but didn't find any differences!

I'm trying to fix it for more than 6 hours, but no way!

Thank you, everyone, for try to help!

1
What versions of PHP are the two servers running?SpacePhoenix
PHP is the same server, running 5.6, I just changed the IP of mysql connection!Zabar
If you echo $order[$i]['value'] what do you get?SpacePhoenix
If i'm connected to the first server, i have so many rows and this value is something like money value... 120,00 / 200,00 / 30,00 and so on! But if I'm connected to the second server, it gets only 1 row, and this value got 0,00.Zabar
@Zabar Maybe a locale problem? How the numbers with comma is interpreted on the different servers?Syscall

1 Answers

0
votes

for avoid the problem you can use a cast for float:

number_format(floatval( trim($order[$i]['value'])), 2, ',', '.')