Zen Cart Logo
Forums / All Other Contributions/Addons / 1064 You have an error in your SQL syntax

1064 You have an error in your SQL syntax

Locked

Views: 837

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
4 Aug 2010, 7:56 PM
#1
nickcb1966 avatar

nickcb1966

New Zenner

Join Date:
Feb 2009
Posts:
15
Plugin Contributions:
0

1064 You have an error in your SQL syntax

I have added additional fields to my product description pages. When I update the product i get the following message:

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 'usage =

I have run an error check and it gives me this:

PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/irrigat2/public_html/tomatopedia.com/admin/includes/modules/product/collect_info.php on line 60

Here is the code:

The area highlighted in red is where the alleged error is.
The blue highlighted text is what I have added.

I used the following thread to achieve do this:
http://www.zen-cart.com/forum/showthread.php?t=57924&highlight=product+details

                   'products_sort_order' => '0',
                   'products_discount_type' => '0',
                   'products_discount_type_from' => '0',
                   'products_price_sorter' => '0',
                   'master_categories_id' => '0',
                   'colour' => '0',
                   'sun_exposure'=> '0',
                   'fruit_weight'=> '0',
                   'resistance'=> '0',
                   'shape' => '0',
                   'habitat' => '0',
                   'growing_conditions' => '0',
                   'maturity' => '0',
                   'usage' => '0',
                   'seed' => '0',
                   'plant_height' => '0',
                   'plant_spacing' => '0',
                   'a_k_a' => '0',
                   'history_description' => '0',
                   'fruit_description' => '0',
                   'plant_description' => '0',
                   'family' => '0',
                   'genus' => '0',
                   'species' => '0'
                   );

$pInfo = new objectInfo($parameters);

if (isset($_GET['pID']) && empty($_POST)) {
  $product = $db->Execute("select pd.products_name, pd.products_description, pd.products_url,
                                  p.products_id, p.products_quantity, p.products_model,
                                  p.products_image, p.products_price, p.products_virtual, p.products_weight,
                                  p.products_date_added, p.products_last_modified,
                                  date_format(p.products_date_available, '%Y-%m-%d') as
                                  products_date_available, p.products_status, p.products_tax_class_id,
                                  p.manufacturers_id,
                                  p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
                                  p.product_is_free, p.product_is_call, p.products_quantity_mixed,
                                  p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
                                  p.products_sort_order,
                                  p.products_discount_type, p.products_discount_type_from,
                                  p.products_price_sorter, p.master_categories_id,
                                  p.colour, p.sun_exposure, p.fruit_weight, p.resistance, p.shape, p.habitat, p.growing_conditions, p.maturity, p.usage, p.seed, p.plant_height, p.plant_spacing, p.a_k_a, p.history_description, p.fruit_description, p.plant_description, p.family, p.genus, p.species
                          from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd
                          where p.products_id = '" . (int)$_GET['pID'] . "'
                          and p.products_id = pd.products_id 
                          and pd.language_id = '" . (int)$_SESSION['languages_id'] . "'");
6 Aug 2010, 11:45 PM
#2
nickcb1966 avatar

nickcb1966

New Zenner

Join Date:
Feb 2009
Posts:
15
Plugin Contributions:
0

Re: 1064 You have an error in your SQL syntax

This is totally confusing me. The problem is fixed if I remove 'usage' => '0', and , p.usage. But, when I replace them, back comes the problem. Anybody any ideas?

7 Aug 2010, 12:15 AM
#3
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
944
Plugin Contributions:
3

Re: 1064 You have an error in your SQL syntax

Maybe try this in the original blue highlighted code:

species' => '0',
);

7 Aug 2010, 12:16 AM
#4
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: 1064 You have an error in your SQL syntax

Two possibilities - no guarantee for either ... either you don't have a column called "usage" in your products table, or "usage" is a reserved word in MySQL which is trying to interpret is as something other than a column name.

7 Aug 2010, 7:30 AM
#5
retched avatar

retched

Totally Zenned

Join Date:
Jun 2007
Location:
Bronx, New York, United States
Posts:
944
Plugin Contributions:
3

Re: 1064 You have an error in your SQL syntax

kuroi:

Two possibilities - no guarantee for either ... either you don't have a column called "usage" in your products table, or "usage" is a reserved word in MySQL which is trying to interpret is as something other than a column name.

Should've thought of that one...

USAGE is indeed a reserved word of MySQL. You can work around this by placing all calls to the usage column in quotes. For example usage or 'usage'.

Reference, MYSQL Reserved Words as listed in section 8.3 of the manual:
http://dev.mysql.com/doc/refman/5.1/en/reserved-words.html

However for simplicity, it's suggested you add something to the usage name like s_usage or fruit_usage of the sort.