Forums / General Questions / Problem with MySQL 5 - 1054 Unknown column 'p.products_id' in 'on clause'

Problem with MySQL 5 - 1054 Unknown column 'p.products_id' in 'on clause'

Locked

Views: 4,497

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
4 Dec 2007, 9:13 PM
#1
tmpanime_com avatar

tmpanime_com

New Zenner

Join Date:
Jul 2005
Posts:
9
Plugin Contributions:
0

Problem with MySQL 5 - 1054 Unknown column 'p.products_id' in 'on clause'

Our web host just upgraded mysql from 4 to 5 without ever informing us, and our zencart site is pretty much dead. I'm running a hacked up version of zencart 1.2.5, and today I'm getting the following error:

1054 Unknown column 'p.products_id' in 'on clause'

At first I was getting this when clicking on a category or a product. I made some changes in the includes\index_filters\default_filter.php and my categories are showing up, but when I click on a product to view the product details, I still get the same error. I don't know which query is creating the problem on this page and would appreciate it if someone can tell me which query i need to fix. Upgrading the site to the latest version of zencart at this time is out of the question because we have too many custom hacks and it would take a major effort.

The main site is at http://www.tmpanime.com. If you click on any product, you will get the above SQL error. I'm getting very frustrated because I get no debug info that gives me any clue on which query in what file is causing this. Thanks much.

4 Dec 2007, 9:49 PM
#2
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
4

Re: Problem with MySQL 5 - 1054 Unknown column 'p.products_id' in 'on clause'

Its most of em,

for mysql 5 you really need to be running at least 1.3.6 but 1371 or 138 would be much better,

Zen cart PCI compliant Hosting

4 Dec 2007, 9:55 PM
#3
tmpanime_com avatar

tmpanime_com

New Zenner

Join Date:
Jul 2005
Posts:
9
Plugin Contributions:
0

Re: Problem with MySQL 5 - 1054 Unknown column 'p.products_id' in 'on clause'

Thanks for the reply, but as of now, it's going to be impossible for me to do an upgrade because we have too many hacks on the site. Like I said, I got the main category listings to work and I just need to get the product info page working. If you can please point me to the actual files that have the queries, I'll figure out the changes. I can't seem to track down the actual queries that makeup the page.

4 Dec 2007, 10:17 PM
#4
drbyte avatar

drbyte

Sensei

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

Re: Problem with MySQL 5 - 1054 Unknown column 'p.products_id' in 'on clause'

You said you're using v1.2.5.
There's no patch available for 1.2.5 directly.
But someone posted a patch a long time ago to work with v1.2.6 and MySQL 5.
You might find it of partial value in mending some queries.
Keep in mind that the patch only deals with some of the more common queries. There are a lot more "fixes" to MySQL queries esp in the admin ... in the v1.3 code.

Patch for v1.2.6: http://download.dataweb.no/files/zen-cart/patch/patch-zc1.2.6d.zip
Use at own risk

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

4 Dec 2007, 10:30 PM
#5
tmpanime_com avatar

tmpanime_com

New Zenner

Join Date:
Jul 2005
Posts:
9
Plugin Contributions:
0

Re: Problem with MySQL 5 - 1054 Unknown column 'p.products_id' in 'on clause'

Thank you, thank you, thank you, thank you!!! That did the trick for now. I guess I'm gonna be upgrading to the latest version this weekend.

22 Jan 2010, 9:44 PM
#6
tecbrat avatar

tecbrat

Zen Follower

Join Date:
Feb 2005
Posts:
239
Plugin Contributions:
0

Re: Problem with MySQL 5 - 1054 Unknown column 'p.products_id' in 'on clause'

My hosting provider gave me some notes and I had to edit them to make them work. This worked on zc 1.2.1

USE WITH CAUTION!! I have no idea what complications this may cause, and if there are any other MySQL5 errors, this won't fix them.

Look in includes/index_filters/default_filter.php

Find this...

    // show the products of a specified manufacturer
       if (isset($_GET['manufacturers_id'])) {
         if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
    // We are asked to show only a specific category
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
         } else {
    // We show them all
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'";
         }
       } else {
    // show the products in a given categorie
         if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id'])) {
    // We are asked to show only specific catgeory
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
         } else {
    // We show them all
           $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
         }
       }
    -------------------------------------
```and replace with this
```php
        // show the products of a specified manufacturer
    if (isset($_GET['manufacturers_id']) && $_GET['manufacturers_id'] != '' ) {
    if (isset($_GET['filter_id']) && zen_not_null($_GET['filter_id'])) {
    // We are asked to show only a specific category
    $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
    } else {
    // We show them all
    $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'";
    }
    } else {
    // show the products in a given categorie
    if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
    // We are asked to show only specific catgeory
    $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['filter_id'] . "' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
    } else {
    // We show them all
    $listing_sql = "select " . $select_column_list . " p.products_id, p.manufacturers_id, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from ((" . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m on p.manufacturers_id = m.manufacturers_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where p.products_status = '1' and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = '" . (int)$languages_id . "' and p2c.categories_id = '" . (int)$current_category_id . "'";
    }
    }