Zen Cart Logo
Forums / General Questions / i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

Views: 3,559

Results 1 to 8 of 8
5 Dec 2018, 6:22 AM
#1
sungmo avatar

sungmo

New Zenner

Join Date:
Jan 2010
Posts:
79
Plugin Contributions:
0

i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

once i click options name manager, options values manager, attributes controller in admin i got an error message "WARNING: An Error occurred, please refresh the page and try again." with blank page.

so i check logs folder. below the message.

[05-Dec-2018 06:02:03 UTC] PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'int)PRODUCTS_OPTIONS_VALUES_TEXT_ID, 1, 'TEXT')' at line 1 :: INSERT INTO products_options_values (products_options_values_id, language_id, products_options_values_name) VALUES ((int)PRODUCTS_OPTIONS_VALUES_TEXT_ID, 1, 'TEXT') in /public_html/includes/classes/db/mysql/query_factory.php on line 120

can someone help?

thanks.

5 Dec 2018, 7:22 AM
#2
dbltoe avatar

dbltoe

Totally Zenned

Join Date:
Jan 2004
Location:
N of San Antonio TX
Posts:
9,783
Plugin Contributions:
11

Re: i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

Might be some help in the similar threads listed below this post.

5 Dec 2018, 12:17 PM
#3
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

@sungmo, what is the history of your store? The value that is causing that error to be generated (PRODUCTS_OPTIONS_VALUES_TEXT_ID) should be a database-based constant.

You can correct the error you posted by copying the following, pasting it into your admin's Tools->Install SQL Patches and pressing 'send':

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('ID for text and file products options values', 'PRODUCTS_OPTIONS_VALUES_TEXT_ID', '0', 'Numeric value of the products_options_values_id used by the text and file attributes.', 6, NULL, now(), now(), NULL, NULL);

Please note that the zc_install process created that constant, so I'm trying to understand how it was removed from the database in the first place.

6 Dec 2018, 12:08 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

One way to identify the how it happened, is to identify what plugins have been installed or attempted to be installed. There used to be a few that would/could clear records of the database that had a gID equal to 0 which included PRODUCTS_OPTIONS_VALUES_TEXT_ID as well as two other constants that previously were assigned to gID=0 instead of how they have been reassigned to gID=6.

6 Dec 2018, 11:56 AM
#5
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

@mc12345678, actually the constant **PRODUCTS_OPTIONS_VALUES_TEXT_ID **has been registered in configuration group ***6 ***(hidden/modules) since at least Zen Cart 1.3.8a timeframe.

That's why I asked the question, since that value isn't one of the three that were previously defined in configuration group 0.

6 Dec 2018, 1:03 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

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

Re: i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

lat9:

@mc12345678, actually the constant **PRODUCTS_OPTIONS_VALUES_TEXT_ID **has been registered in configuration group ***6 ***(hidden/modules) since at least Zen Cart 1.3.8a timeframe.

That's why I asked the question, since that value isn't one of the three that were previously defined in configuration group 0.
My bad, I was thinking mostly of PRODUCTS_OPTIONS_TYPE_SELECT although there were two other configuration_key values that also were stored at gID of 0. Those other two though were not in mind. The request of what plugins had been installed or attempted to be installed/removed still remains as an action. Even though I wrongly attributed PRODUCTS_OPTIONS_VALUE_TEXT_ID to what used to be more of a problem.

If the issue is associated to some plugin software, then knowing which one would help prevent the same thing from occurring to others.

16 Dec 2018, 9:00 PM
#7
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

lat9:

@sungmo, what is the history of your store? The value that is causing that error to be generated (PRODUCTS_OPTIONS_VALUES_TEXT_ID) should be a database-based constant.

You can correct the error you posted by copying the following, pasting it into your admin's Tools->Install SQL Patches and pressing 'send':

INSERT INTO configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, last_modified, date_added, use_function, set_function) VALUES ('ID for text and file products options values', 'PRODUCTS_OPTIONS_VALUES_TEXT_ID', '0', 'Numeric value of the products_options_values_id used by the text and file attributes.', 6, NULL, now(), now(), NULL, NULL);

> Please note that the zc_install process created that constant, so I'm trying to understand how it was removed from the database in the first place.

> **mc12345678:**
>
> One way to identify the how it happened, is to identify what plugins have been installed or attempted to be installed. There used to be a few that would/could clear records of the database that had a gID equal to 0 which included PRODUCTS_OPTIONS_VALUES_TEXT_ID as well as two other constants that previously were assigned to gID=0 instead of how they have been reassigned to gID=6.

> **lat9:**
>
> @mc12345678, actually the constant **PRODUCTS_OPTIONS_VALUES_TEXT_ID **has been registered in configuration group ***6 ***(hidden/modules) since at least Zen Cart 1.3.8a timeframe. 
> 
> That's why I asked the question, since that value isn't one of the three that were previously defined in configuration group **0**.

> **mc12345678:**
>
> My bad, I was thinking mostly of PRODUCTS_OPTIONS_TYPE_SELECT although there were two other configuration_key values that also were stored at gID of 0. Those other two though were not in mind. The request of what plugins had been installed or attempted to be installed/removed still remains as an action. Even though I wrongly attributed PRODUCTS_OPTIONS_VALUE_TEXT_ID to what used to be more of a problem.
> 
> If the issue is associated to some plugin software, then knowing which one would help prevent the same thing from occurring to others.
 No, y'all missed an important distinction here. 
See how the SQL quoted in the error here: "... VALUES (**(int)**PRODUCTS_OPTIONS_VALUES_TEXT_ID, 1, 'TEXT')... contains the PHP (int) directive? 
While if the "(int)" weren't part of the error message you'd be right, since the error message includes the PHP code for (int), it means someone has tampered with the code and is outputting the PHP into the SQL. 
Solution: put back the original code instead of whatever has been done to change it.
16 Dec 2018, 9:02 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,085
Plugin Contributions:
56

Re: i got error message "PHP Fatal error: 1064:You have an error in your SQL syntax;"

Spot on, as usual, DrByte!:smile: