Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

1054 - Unknown column 'p.manufacturers_id' in 'on clause'


ShaGGy

Recommended Posts

Posted

Help!

 

I have been getting the error

1054 - Unknown column 'p.manufacturers_id' in 'on clause'

 

select distinct p.products_id, p.products_image, p.products_model, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price, mnf.manufacturers_name, rvw.reviews_rating from products p left join specials s on p.products_id = s.products_id, products_to_categories p2c, categories c left join manufacturers mnf on p.manufacturers_id = mnf.manufacturers_id left join reviews rvw on p.products_id = rvw.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '31' and p.products_status = '1' order by rand() DESC limit 12

 

[TEP STOP]

 

the error shows when i go into a sub category (i.e after clicking the category menu item) but when I go into the category (I.e where it lists the products) there is no error.

 

I believe this may be something to do with PHP5 as I had other errors which I have managed to fix by editing the Index.php and Advanced_search_result.php

 

If any of you PHP wizards can help me out I would be greatfull

 

Thanks

Posted
Has your server recently migrated your site or upgraded your mySQL buy chance? I am having a very similar problem that JUST occured after my server migrated my site. My post is 1054 - Unknown column 'p.products_id' in 'on clause' , hopfully someone will able to help us by posting in one of these threads. :rolleyes:

 

 

Yes mine has upgraded but my problem is slightly different from your error where mine is Select Distinct

:(

I think it is something to do with the Index.php file but been trying to find a solution for days now and getting nowhere

Posted

follow these instructions, if you find that your code is not the same when you are seaching then just find the code that looks the same and replace it with fixed one.

if you are getting this problem it means you are using out of date OSC/template version

 

 

In Catalog/index.php file..

Find this...


// show the products of a specified manufacturer
  if (isset($HTTP_GET_VARS['manufacturers_id'])) {
 if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['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)$HTTP_GET_VARS['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)$HTTP_GET_VARS['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)$HTTP_GET_VARS['manufacturers_id'] . "'";
 }
  } else {
// show the products in a given categorie
 if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['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)$HTTP_GET_VARS['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

// show the products of a specified manufacturer
if (isset($HTTP_GET_VARS['manufacturers_id'])) {
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['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)$HTTP_GET_VARS['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)$HTTP_GET_VARS['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)$HTTP_GET_VARS['manufacturers_id'] . "'";
}
} else {
// show the products in a given categorie
if (isset($HTTP_GET_VARS['filter_id']) && tep_not_null($HTTP_GET_VARS['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)$HTTP_GET_VARS['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 . "'";
}
}

-------------------------------------------------------------------
In catalog/advanced_search_result.php 

Find this


$from_str = "from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

----------------------------------------
and replace with this


$from_str = "from ((" . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

Posted

Thanks for that but I have already made them changes and it fixed the original problems but this one was not fixed

 

1054 - Unknown column 'p.manufacturers_id' in 'on clause'

 

select distinct p.products_id, p.products_image, p.products_model, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price, mnf.manufacturers_name, rvw.reviews_rating from products p left join specials s on p.products_id = s.products_id, products_to_categories p2c, categories c left join manufacturers mnf on p.manufacturers_id = mnf.manufacturers_id left join reviews rvw on p.products_id = rvw.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '31' and p.products_status = '1' order by rand() DESC limit 12

 

where most other peoples problem says

 

1054 - Unknown column 'p.manufacturers_id' in 'on clause'

 

select count(*) as total from products p, categories c, products_to_categories p2c left join manufacturers m on (p.manufacturers_id = m.manufacturers_id), products_description pd where c.categories_status=1 and p.products_id = p2c.products_id and c.categories_id = p2c.categories_id and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '2'

 

I have search everywhere for this error and failing badly so if someone can help i'd be greatful.

Posted

Thanks - none_uk -

 

Worked like a charm... and for future references 4 people with old templates... this is your fix...!

 

Again, thanks- saved a lot of time...!

Posted

Managed to fix it by editing the /includes/modules/new_products.php

 

	 $sql = "select distinct p.products_id, p.products_image, p.products_model, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price, mnf.manufacturers_name, rvw.reviews_rating from " . TABLE_PRODUCTS . " p left join ".TABLE_SPECIALS." s on p.products_id = s.products_id left join ".TABLE_MANUFACTURERS." mnf on p.manufacturers_id = mnf.manufacturers_id left join ".TABLE_REVIEWS." rvw on p.products_id = rvw.products_id where p.products_status = '1' order by rand() DESC limit ".MAX_DISPLAY_NEW_PRODUCTS;
$new_products_query = tep_db_query($sql);
$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where c.categories_status='1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
	$new_products_query = tep_db_query($sql);

To

 $sql = "select distinct p.products_id, p.products_image, p.products_model, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price, mnf.manufacturers_name, rvw.reviews_rating from (" . TABLE_PRODUCTS . " p) left join ".TABLE_SPECIALS." s on p.products_id = s.products_id left join ".TABLE_MANUFACTURERS." mnf on p.manufacturers_id = mnf.manufacturers_id left join ".TABLE_REVIEWS." rvw on p.products_id = rvw.products_id where p.products_status = '1' order by rand() DESC limit ".MAX_DISPLAY_NEW_PRODUCTS;
$new_products_query = tep_db_query($sql);
$new_products_query = tep_db_query("select p.products_id, p.products_image, p.products_tax_class_id, if(s.status, s.specials_new_products_price, p.products_price) as products_price from (" . TABLE_PRODUCTS . " p) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c where c.categories_status='1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and products_status = '1' order by p.products_date_added desc limit " . MAX_DISPLAY_NEW_PRODUCTS);
	$new_products_query = tep_db_query($sql);

Posted

suspect a more complete list is in here

 

http://www.oscommerce.com/ext/update-20060817.txt

Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile

 

Virus Threat Scanner

My Contributions

Basic install answers.

Click here for Contributions / Add Ons.

UK your site.

Site Move.

Basic design info.

 

For links mentioned in old answers that are no longer here follow this link Useful Threads.

 

If this post was useful, click the Like This button over there ======>>>>>.

Posted

Once again a sincere thank you to the community that makes osC so great - can't express enough how much I appreciate all the effort you guys and gals put in here on the forums!

 

Had the stated error message, did a search, found the thread, problem fixed in under 10 minutes - as usual the community comes to my rescue!

 

Thank you all once again!

 

Ron

  • 1 month later...
Posted

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

select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from products p left join specials s on p.products_id = s.products_id, products_to_categories p2c, categories c left join featured f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '24' and p.products_status = '1' and f.status = '1' order by rand() DESC limit 12

[TEP STOP]

 

Have the same problem, i cant find fix for this :(

 

 

 

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

select p.products_id, pd.products_name, p.products_image, IF(s.status, s.specials_new_products_price,p.products_price) as products_price from products p, products_description pd, categories c, products_to_categories p2c left join specials s on p.products_id = s.products_id where products_status = '1' and p.products_id = pd.products_id and pd.language_id = '4' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.status = '1' order by p.products_last_modified DESC limit 4

 

Need help for fix this ,

Posted

The first field in the 'products' table in the database is 'products_id' and when you see p.products_id it means the products id field in the products table (p is short for products).

 

This error means that the 'products_id' field is missing from the 'products' table in the database.

 

Vger

Posted

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

select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from products p left join specials s on p.products_id = s.products_id, products_to_categories p2c, categories c left join featured f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '24' and p.products_status = '1' and f.status = '1' order by rand() DESC limit 12

[TEP STOP]

 

I Fix it:

 

 

 

In file /includes/modules/featured.php

 

 

Change:

 

$featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price FROM " . TABLE_PRODUCTS . " p LEFT JOIN " . TABLE_SPECIALS . " s ON (p.products_id = s.products_id), " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c LEFT JOIN " . TABLE_FEATURED . " f ON (p.products_id = f.products_id) where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);

 

by:

 

$featured_products_query = tep_db_query("select distinct p.products_id, p.products_image, p.products_tax_class_id, s.status as specstat, s.specials_new_products_price, p.products_price from ".TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id left join " . TABLE_FEATURED . " f on p.products_id = f.products_id where p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and c.parent_id = '" . $featured_products_category_id . "' and p.products_status = '1' and f.status = '1' order by rand() DESC limit " . MAX_DISPLAY_FEATURED_PRODUCTS);}

  • 1 year later...
Posted

Hi every body, i am new in here, i think iv messed up my advanced_search_result.php. can any one checked this code and fixe for me. it will be great pleasure for me.xxxxx

 

 

 

<?php

/*

$Id: advanced_search_result.php,v 1.1.1.1 2004/03/04 23:37:54 ccwjr Exp $

 

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

 

Copyright © 2003 osCommerce

 

Released under the GNU General Public License

*/

 

require('includes/application_top.php');

 

require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH);

 

 

$error = false;

 

if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) &&

(isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) &&

(isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) &&

(isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) &&

(isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) {

$error = true;

 

$messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);

} else {

$dfrom = '';

$dto = '';

$pfrom = '';

$pto = '';

$keywords = '';

 

if (isset($HTTP_GET_VARS['dfrom'])) {

$dfrom = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']);

}

 

if (isset($HTTP_GET_VARS['dto'])) {

$dto = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']);

}

 

if (isset($HTTP_GET_VARS['pfrom'])) {

$pfrom = $HTTP_GET_VARS['pfrom'];

}

 

if (isset($HTTP_GET_VARS['pto'])) {

$pto = $HTTP_GET_VARS['pto'];

}

 

if (isset($HTTP_GET_VARS['keywords'])) {

$keywords = $HTTP_GET_VARS['keywords'];

}

 

$date_check_error = false;

if (tep_not_null($dfrom)) {

if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) {

$error = true;

$date_check_error = true;

 

$messageStack->add_session('search', ERROR_INVALID_FROM_DATE);

}

}

 

if (tep_not_null($dto)) {

if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) {

$error = false;

$date_check_error = false;

 

$messageStack->add_session('search', ERROR_INVALID_TO_DATE);

}

}

 

if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) {

if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) {

$error = false;

 

$messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE);

}

}

 

$price_check_error = false;

if (tep_not_null($pfrom)) {

if (!settype($pfrom, 'double')) {

$error = true;

$price_check_error = true;

 

$messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM);

}

}

 

if (tep_not_null($pto)) {

if (!settype($pto, 'double')) {

$error = true;

$price_check_error = true;

 

$messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM);

}

}

 

if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) {

if ($pfrom >= $pto) {

$error = true;

 

$messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM);

}

}

 

if (tep_not_null($keywords)) {

if (!tep_parse_search_string($keywords, $search_keywords)) {

$error = true;

 

$messageStack->add_session('search', ERROR_INVALID_KEYWORDS);

}

}

}

 

if (empty($dfrom) && empty($dto) && empty($pfrom) && empty($pto) && empty($keywords)) {

$error = true;

 

$messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);

}

 

if ($error == true) {

tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false));

}

 

$breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH));

$breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, tep_get_all_get_params(), 'NONSSL', true, false));

 

$content = CONTENT_ADVANCED_SEARCH_RESULT;

 

require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE);

 

require(DIR_WS_INCLUDES . 'application_bottom.php');

$from_str = "from ((" . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

 

if ( (DISPLAY_PRICE_WITH_TAX == 'true') && (tep_not_null($pfrom) || tep_not_null($pto)) ) {

if (!tep_session_is_registered('customer_country_id')) {

$customer_country_id = STORE_COUNTRY;

$customer_zone_id = STORE_ZONE;

}

$from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";

}

 

$from_str = "from ((" . TABLE_PRODUCTS . " p) left join " . TABLE_MANUFACTURERS . " m using(manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c";

 

$where_str = " where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id ";

?>

  • 9 months later...
Posted

Wow ... this was absurd. I have only like 3 addons addons (the affiliate addon what the tough one - 15 files I had to edit) ... resulting in me having to update a whopping 21 files. What a royal pain in the neck.

 

The trick is that I don't even have telnet access ... I used a phpgrep.php program to search for all files that contained "join" in it.

 

Whew. Am glad it's now done ... on that store! I have 3 more stores to do this with! At least now I know what files I need to edit.

 

Bleah!

 

Not even sure I did it right in some cases ... like how do you do this one:

    $from_str .= " left join " . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";

There's not "from" on the left side against which you'd normally put the left bracket. There's a "$from_str" but that's obviously a variable, not a "from" command. I don't know. I did this to it, maybe it will work:

    $from_str .= " left join (" . TABLE_TAX_RATES . " tr on p.products_tax_class_id = tr.tax_class_id) left join " . TABLE_ZONES_TO_GEO_ZONES . " gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = '0' or gz.zone_country_id = '" . (int)$customer_country_id . "') and (gz.zone_id is null or gz.zone_id = '0' or gz.zone_id = '" . (int)$customer_zone_id . "')";

I'm guessing the ".=" is an append operator ... I don't know, website works now though ... haven't fully tested it out, but I'm hoping all is good.

 

-Dave

Posted

Why can't anyone do a search? This will explain what's behind everything: http://www.oscommerce.com/forums/topic/335136-osc-and-mysql-5-1054-errors . You need to understand what's going on, rather than just trying to change code by rote. Summary: for MySQL 5, if you have a comma-separated list of tables between "FROM" and "JOIN", you need to wrap parentheses ( ) around the list of tables. That way it will behave the same way as MySQL 3 and 4 did.

Posted

Looks like Dreamhost upgraded me to sql5 recently, so I'll be adding the ( ) tonight. Thank's for the info though, I was certainly worried when I saw that my catalogue had gone to hell. I may be back with more questions though.

Dan

Posted

Errrr, I think I understand the need for the () after the from, and before the join, but I'm still having troubles. My home page shows up fine, but when I click on a catagorie, I get a white page with the sub-catagorie icons, and the new products below, and the error at the bottom of the page. As long as there are more sub-catagories, I can keep going, but when I get to the point where there are no more sub-catagories, I just get an error. This is the same error as on the bottom of the other error pages.

 

Now, the home page looks normal, and the actual product pages looks normal, but if I start going through the catagories, I get the error.

 

Everything else seems to be working correctly, orders are still being processed for the items that are Featured on the home page, or new items on the home page, but navigating the catagories looks aweful.

 

www.swiftmotorsports.com is the site if anyone wants to see what I'm talking about.

 

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

 

select count(p.products_id) as total from (products_description pd, products p) left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c left join 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 = '1' and p2c.categories_id = '2015'

 

Anyhelp would be huge. I've edited all of the previously mentioned files, do I need to go through every file on the site in case something else is causing this? I got this site when I bought the company, so I didn't do the initial setup, so I'm a little lost here.

Dan

Posted

You forgot the parentheses that you actually needed:

select count(p.products_id) as total from ((products_description pd, products p) left join manufacturers m on p.manufacturers_id = m.manufacturers_id, products_to_categories p2c) left join 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 = '1' and p2c.categories_id = '2015'

It doesn't hurt to leave the pair around pd and p, although they're unnecessary.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...