You are on page 1of 5

http://forums.oscommerce.com/lofiversion/index.php?t288929.

html

full version: 1054 - unknown column 'p.products_id' in 'on clause' please help!
oscommerce community support forums > oscommerce online merchant v2.x > general
support
xpcpro
jan 10 2008, 06:09 pm
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 =
'35'

[tep stop]

can someone help me? (this shows when i click on a "category"


geoffreywalton
jan 10 2008, 07:13 pm
i believe your problem is related to mysql version 5.

patches to correct this are included with each release of oscommerce and are
generally in the extras directory. the files have names like update-yyyymmdd.html
and update-yyyymmdd.txt.

these files contain a shed load of patches that should be applied to a stock
install, but as this is not shown as a step in the documentation / installation
instruction that i have read, most people won't until they run into a problem.
then they will find a solution to one problem via the forums.

here is the index of mine.

oscommerce 2.2 milestone 2 update 051113


update package 13th november 2005

------------------------------------------------------------------------------
table of contents
------------------------------------------------------------------------------

## update 051113

customer_country_id in addressbook

## update 051112

cannot re-assign $this


limit -20, 20
database input enhancement
adding non-existing products to cart
session id xss issue
validate session id
file manager problem
http header injection
e-mail header injection
contact us form xss issue
open redirector
extra slashes in new products
order status filtering
mysql 5.0 compatibility

and here is the mysql 5.0 compatibility entries

------------------------------------------------------------------------------
mysql 5.0 compatibility
------------------------------------------------------------------------------

problem:

mysql 5.0 introduces server sql modes as part of its sql 2003 standards support,
and uses a more stricter approach to executing sql queries. this is performed by
default with setting strict_trans_tables as a server sql mode.

due to this new setting, mysql fails on certain sql queries and produces error
messages on the screen.

solution:

lines 213-223 in catalog/advanced_search_result.php must be changed from:

$from_str = "from " . table_products . " p left join " . table_manufacturers . " m
using(manufacturers_id) left join " . table_specials . " s on p.products_id =
s.products_id, " . table_products_description . " pd, " . 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 . "')";
}

$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 ";

to:

$from_str = "from " . table_products . " p left join " . table_manufacturers . " m
using(manufacturers_id) left join " . table_specials . " s on p.products_id =
s.products_id";

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 .= ", " . table_products_description . " pd, " . 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 ";

the following lines must be replaced in catalog/index.php:

line 175, from:

$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'] . "'";

to:

$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 left join " . table_specials . " s on p.products_id =
s.products_id, " . table_products_description . " pd, " . table_manufacturers . "
m, " . table_products_to_categories . " p2c 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'] . "'";

line 178, from:

$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'] . "'";

to:
$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 left join " . table_specials . " s on p.products_id =
s.products_id, " . table_products_description . " pd, " . table_manufacturers . "
m 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'] . "'";

line 184, from:

$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 . "'";

to:

$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 left join " . table_specials . " s on p.products_id =
s.products_id, " . table_products_description . " pd, " . table_manufacturers . "
m, " . table_products_to_categories . " p2c 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 . "'";

line 187, from:

$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 .
"'";

to:

$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 left join " .
table_specials . " s on p.products_id = s.products_id, " .
table_products_to_categories . " p2c 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 . "'";

line 292 in catalog/admin/categories.php must be changed from:

tep_db_query("insert into " . table_products . " (products_quantity,


products_model,products_image, products_price, products_date_added,
products_date_available, products_weight, products_status, products_tax_class_id,
manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "',
'" . tep_db_input($product['products_model']) . "', '" .
tep_db_input($product['products_image']) . "', '" .
tep_db_input($product['products_price']) . "', now(), '" .
tep_db_input($product['products_date_available']) . "', '" .
tep_db_input($product['products_weight']) . "', '0', '" .
(int)$product['products_tax_class_id'] . "', '" .
(int)$product['manufacturers_id'] . "')");

to:

tep_db_query("insert into " . table_products . " (products_quantity,


products_model,products_image, products_price, products_date_added,
products_date_available, products_weight, products_status, products_tax_class_id,
manufacturers_id) values ('" . tep_db_input($product['products_quantity']) . "',
'" . tep_db_input($product['products_model']) . "', '" .
tep_db_input($product['products_image']) . "', '" .
tep_db_input($product['products_price']) . "', now(), " .
(empty($product['products_date_available']) ? "null" : "'" .
tep_db_input($product['products_date_available']) . "'") . ", '" .
tep_db_input($product['products_weight']) . "', '0', '" .
(int)$product['products_tax_class_id'] . "', '" .
(int)$product['manufacturers_id'] . "')");

the following sql queries need to be performed:

alter table whos_online modify column last_page_url varchar(255) not null;

alter table customers modify column customers_default_address_id integer;

alter table customers_basket modify column final_price decimal(15,4);


lina003
jan 10 2008, 07:35 pm
i don't remember off the top of my head, but if you search this forum you'll find
the answer pretty quickly - it's a common problem.

i believe there is a contribution for it.


nimz
jan 10 2008, 07:45 pm
this issue is mentioned several times in the forum.
run a search.
this is a "lo-fi" version of our main content. to view the full version with more
information, formatting and images, please click here.
invision power board � 2001-2008 invision power services, inc.