Zen Cart Logo
Forums / Upgrading to 1.5.x / PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

Views: 6,405

Results 1 to 8 of 8
21 Dec 2019, 9:30 PM
#1
doomm avatar

doomm

New Zenner

Join Date:
Sep 2008
Posts:
54
Plugin Contributions:
0

PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

Hi guys,

I´m stuck here...

after upgrade to 1.5.6a (from 1.5.4) I have noticed a problem which I cannot solve.

When trying to update a product or add one, I recieve this message:

WARNING: An Error occurred, please refresh the page and try again.If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.

after looking to my logs, it seems that there is some problem with products_price in database and incorrect decimal value:

[21-Dec-2019 21:11:05 UTC] Request URI: /admin/product.php?cPath=62&pID=1198&action=update_product, IP address: xxx
#1 trigger_error() called at [/home/xxx/public_html/includes/classes/db/mysql/query_factory.php:171]
#2 queryFactory->show_error() called at [/home/xxxx/public_html/includes/classes/db/mysql/query_factory.php:143]
#3 queryFactory->set_error() called at [/home/xxxx/public_html/includes/classes/db/mysql/query_factory.php:270]
#4 queryFactory->Execute() called at [/home/xxxx/public_html/admin/includes/functions/database.php:51]
#5 zen_db_perform() called at [/home/xxxx/public_html/admin/includes/modules/update_product.php:83]
#6 require(/home/xxxx/public_html/admin/includes/modules/update_product.php) called at [/home/xxxx/public_html/admin/product.php:34]
--> PHP Fatal error: 1366:Incorrect decimal value: '53,9167' for column 'products_price' at row 1 :: update products set products_quantity = '12', products_type = '1', products_model = 'code', products_price = '53,9167', products_date_available = null, products_weight = '0', products_status = '1', products_virtual = '0', products_tax_class_id = '1', manufacturers_id = '0', products_quantity_order_min = '1', products_quantity_order_units = '1', products_priced_by_attribute = '0', product_is_free = '0', product_is_call = '0', products_quantity_mixed = '1', product_is_always_free_shipping = '0', products_qty_box_status = '1', products_quantity_order_max = '0', products_sort_order = '0', products_discount_type = '0', products_discount_type_from = '0', products_price_sorter = '53,9167', products_image = 'image.jpg', products_last_modified = now(), master_categories_id = '62' where products_id = 1198 ==> (as called by) /home/xxxx/public_html/admin/includes/functions/database.php on line 51 <== in /home/xxxx/public_html/includes/classes/db/mysql/query_factory.php on line 171.

my other eshops based on 1.5.4 are fully functional on the same server,

I use PHP 7.2.25 and MySQL 5.6.45

Any idea, please, what went wrong here? I recieve this message on both e-shops I have upgraded to 1.5.6a (actually, one of them is already on 1.5.6c - I didn´t realized this problem before another upgrade)

22 Dec 2019, 6:58 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

The numbers need to have/use a dot for the decimal when storing such a number. Perhaps the previous store(s) were modified to do this or handle it differently, but a decimal number should not include a thousands separator and should be stored with a period for the decimal such that the product's price should be entered as '53.9167' instead of '53,9167'.

22 Dec 2019, 7:44 AM
#3
doomm avatar

doomm

New Zenner

Join Date:
Sep 2008
Posts:
54
Plugin Contributions:
0

Re: PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

Thanks for trying to help, mc12345678,

problem is these prices are stored in db with a dot and I see them in the admin with a dot...

I can update a product directly through db without problems,

stores didn´t have this problem before the upgrade - I updated products regularly...

Could you please point me where should I look?

22 Dec 2019, 8:18 AM
#4
doomm avatar

doomm

New Zenner

Join Date:
Sep 2008
Posts:
54
Plugin Contributions:
0

Re: PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

Update - now I found that problem is somehow related to languages - everything works fine in english, problem is when I change the languate to another one (slovak in my case). Will work on that and try what I did wrong :-)

22 Dec 2019, 9:55 AM
#5
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

I am thinking that perhaps there is javascript associated with the page changes that may/may not have been involved with this. I'm not entirely sure how the selection of the current currency is incorporated into the step through process of storing a product but it seems to me that it only occurs in one place to display the value not to store it.

Perhaps could also explain how the site was upgraded? There were some significant changes that could possibly explain a discrepancy occurring.

22 Dec 2019, 4:32 PM
#6
doomm avatar

doomm

New Zenner

Join Date:
Sep 2008
Posts:
54
Plugin Contributions:
0

Re: PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

It´s true that sites were not updated exactly by the book - I just uploaded all new files, updated db through zc_install and one by one updated all plugins (there are only a few ones),

what´s confusing for me is that I don´t have this problem when I switch the site to english - I´ll investigate this further and will post if I´ll find the answer.

22 Dec 2019, 5:13 PM
#7
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

Doomm:

It´s true that sites were not updated exactly by the book - I just uploaded all new files, updated db through zc_install and one by one updated all plugins (there are only a few ones),

what´s confusing for me is that I don´t have this problem when I switch the site to english - I´ll investigate this further and will post if I´ll find the answer.
When you say that you just uploaded all new files, was that to an empty directory or did these files overwrite existing files?

Each language has its own definition of how to handle numbers and whether to use a comma for the decimal separator, period or some other character. What I was looking at and for was any handler that would operate on the data either downloaded from the database or manually entered.

One possibility of where the issue appears may be in the admin sanitizer if it is locale aware. Thing is, I know there are some others that operate in alternate languages where the language uses a comma for the decimal point but has been able to "work around" this issue if it is in fact something central to the core code.

So, what other plugins are installed and/or language(s) used?

And still have the question from above about uploading new files to a new empty directory or did the files overwrite existing files?

22 Dec 2019, 6:07 PM
#8
doomm avatar

doomm

New Zenner

Join Date:
Sep 2008
Posts:
54
Plugin Contributions:
0

Re: PHP Fatal error: 1366:Incorrect decimal value after upgrade to 1.5.6

I found it,

problem was in line 24 in the main language file in admin (slovak.php in my case). This was my old line:

setlocale(LC_ALL, "sk_SK.utf-8");

after copying it from the actual english.php file to:

@setlocale(LC_TIME, $locales);

everything seems to be working correctly.

Actually, I have changed also line before from english.php:

$locales = array('en_US', 'en_US.utf8', 'en', 'English_United States.1252');
@setlocale(LC_TIME, $locales);

to slovak.php:

$locales = array('sk_SK', 'sk_SK.utf8', 'sk', 'Slovak_Slovakia.1250');
@setlocale(LC_TIME, $locales);

not sure what this change really means, but as I said, it works fine.

Just a few comments, maybe they will be handy for someone:

  • yes, in the slovak language, it´s used comma instead of dot in numbers (not sure though how this is linked to language file)
  • I didn´t change language files immediately after update, never happened this problem to me before, now I´ll think about it right away
  • yes these uploaded files overrride old files on the server. (Obviously, it overrides also english language files, not slovak ones)

All in all, I hope this is it. Mc12345678 you have helped me a lot to find the right path, thank you very much for your time and effort. Community here is the main reason why I´m still with Zencart after all those years. Thanks again, buddy.