Forums / Addon Templates / Additional Product Images WITH MYSQL 5.7.23 does not work

Additional Product Images WITH MYSQL 5.7.23 does not work

Views: 4,403

Results 1 to 4 of 4
16 Jan 2019, 10:50 AM
#1
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Additional Product Images WITH MYSQL 5.7.23 does not work

Additional Product Images - Version: 2.1

I'm working locally with mamp pro, mysql version 5.7.23 and php 7.1.22

When I load an additional image it gives me error 503 and this error log;

[16-Jan-2019 10:46:56 Europe/Rome] Request URI: /ADMIN/additional_product_images_upload.php?products_id=108&action=insert, IP address: ::1
#1 trigger_error() called at [/Applications/MAMP/htdocs/MYDOMAINE/includes/classes/db/mysql/query_factory.php:171]
#2 queryFactory->show_error() called at [/Applications/MAMP/htdocs/MYDOMAINE/includes/classes/db/mysql/query_factory.php:143]
#3 queryFactory->set_error() called at [/Applications/MAMP/htdocs/MYDOMAINE/includes/classes/db/mysql/query_factory.php:270]
#4 queryFactory->Execute() called at [/Applications/MAMP/htdocs/MYDOMAINE/Hoist-gzM-Adult/additional_product_images_upload.php:45]

with mysql version 5.6 everything works fine

[16-Jan-2019 10:46:56 Europe/Rome] PHP Fatal error: 1364:Field 'category_id' doesn't have a default value :: insert into additional_images
(products_id, additional_image, status)
values ('108',
'additional/myimage.jpg',
'1') ==> (as called by) /Applications/MAMP/htdocs/MYDOMAINE/ADMIN/additional_product_images_upload.php on line 45 <== in /Applications/MAMP/htdocs/MYDOMAINE/includes/classes/db/mysql/query_factory.php on line 171

$db->Execute("insert into " . TABLE_ADDITIONAL_IMAGES . "
                    (products_id, additional_image, status)
                    values ('" . zen_db_input((int)$_GET['products_id']) . "',
                            '" . $additional_image_name . "',
                            '1')");

Thanks for your help

Giovanni,
Zen Cart V2.1

16 Jan 2019, 11:00 AM
#2
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Additional Product Images WITH MYSQL 5.7.23 does not work

You can solve that by going to your phpmyadmin (or equivalent) and add a default value of 0 to categories_id in the table structure of additional_images.
This a new feature on mysql5.7, where a integer field needs a value in the query, or else it will fail, unless you have set a default value.

diamond1:

Additional Product Images - Version: 2.1

I'm working locally with mamp pro, mysql version 5.7.23 and php 7.1.22

When I load an additional image it gives me error 503 and this error log;

[16-Jan-2019 10:46:56 Europe/Rome] Request URI: /ADMIN/additional_product_images_upload.php?products_id=108&action=insert, IP address: ::1
#1 trigger_error() called at [/Applications/MAMP/htdocs/MYDOMAINE/includes/classes/db/mysql/query_factory.php:171]
#2 queryFactory->show_error() called at [/Applications/MAMP/htdocs/MYDOMAINE/includes/classes/db/mysql/query_factory.php:143]
#3 queryFactory->set_error() called at [/Applications/MAMP/htdocs/MYDOMAINE/includes/classes/db/mysql/query_factory.php:270]
#4 queryFactory->Execute() called at [/Applications/MAMP/htdocs/MYDOMAINE/Hoist-gzM-Adult/additional_product_images_upload.php:45]

with mysql version 5.6 everything works fine

[16-Jan-2019 10:46:56 Europe/Rome] PHP Fatal error: 1364:Field 'category_id' doesn't have a default value :: insert into additional_images
(products_id, additional_image, status)
values ('108',
'additional/myimage.jpg',
'1') ==> (as called by) /Applications/MAMP/htdocs/MYDOMAINE/ADMIN/additional_product_images_upload.php on line 45 <== in /Applications/MAMP/htdocs/MYDOMAINE/includes/classes/db/mysql/query_factory.php on line 171

$db->Execute("insert into " . TABLE_ADDITIONAL_IMAGES . "
(products_id, additional_image, status)
values ('" . zen_db_input((int)$_GET['products_id']) . "',
'" . $additional_image_name . "',
'1')");

> 
> Thanks for your help
16 Jan 2019, 11:39 AM
#3
diamond1 avatar

diamond1

Zen Follower

Join Date:
Jan 2010
Location:
France
Posts:
295
Plugin Contributions:
0

Re: Additional Product Images WITH MYSQL 5.7.23 does not work

It worked!!

You are a magician Thanks
How did you understand that I had to put null default value of null to categories_id?

I confirm it works also with the lower version mysql 5.5 and 5.6
Thanks ZZZ if one day passes from Brussels contact me we take a coffee

Giovanni,
Zen Cart V2.1

16 Jan 2019, 11:49 AM
#4
design75 avatar

design75

Totally Zenned

Join Date:
Dec 2009
Location:
Amersfoort, The Netherlands
Posts:
2,862
Plugin Contributions:
5

Re: Additional Product Images WITH MYSQL 5.7.23 does not work

It was not that hard, as it is a common problem on newer mysql versions.
By the way it should be 0, not null, as the field expects an integer, and null is not an integer.

Thanks for the invitation :smile:.