{"id":41,"date":"2008-02-04T07:56:17","date_gmt":"2008-02-04T13:56:17","guid":{"rendered":"http:\/\/blog.edynamo.com\/?p=41"},"modified":"2009-02-18T07:57:22","modified_gmt":"2009-02-18T13:57:22","slug":"osc-mysql-5-issue","status":"publish","type":"post","link":"http:\/\/edynamo.com\/blog\/?p=41","title":{"rendered":"osC mySQL 5 issue"},"content":{"rendered":"<p>Upgrading\u00a0the\u00a0servers\u00a0to\u00a0MySQL\u00a0ver.5\u00a0often results\u00a0in breaking working\u00a0osCommerce sites. If you get a MySQL error (most often error #1054) on a finished project that was working, it\u00a0is\u00a0most\u00a0probably\u00a0this\u00a0issue. Read down to learn how to solve it.<\/p>\n<p>Patch the resepective file where you get the error. Here\u00a0are the\u00a0error\u00a0codes:<\/p>\n<p><strong>Details:\u00a0\u00bb\u00bb\u00bb<\/strong><\/p>\n<p>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.<\/p>\n<p>Due to this new setting, MySQL fails on certain SQL queries and produces error messages on the screen.<\/p>\n<p><strong>\u00bb\u00bb\u00bb<\/strong><\/p>\n<p><strong>If the problem occurs in:<\/strong><\/p>\n<ul>\n<li><a href=\"http:\/\/212.116.129.86\/joomla\/index.php?option=com_content&amp;task=view&amp;id=76&amp;Itemid=2#asr\">advanced_search_result.php<\/a><\/li>\n<li><a href=\"http:\/\/212.116.129.86\/joomla\/index.php?option=com_content&amp;task=view&amp;id=76&amp;Itemid=2#idx\">index.php<\/a><\/li>\n<li><a href=\"http:\/\/212.116.129.86\/joomla\/index.php?option=com_content&amp;task=view&amp;id=76&amp;Itemid=2#cats\">\/admin\/categories.php<\/a><\/li>\n<\/ul>\n<p><strong><a title=\"asr\" name=\"asr\"><\/a>ADVANCED SEARCH RESULTS<\/strong><strong>Solution:\u00a0<\/strong>Lines 213-223 in catalog\/<strong>advanced_search_result.php<\/strong>\u00a0must be changed from:<\/p>\n<p>$from_str = &#8220;from &#8221; . TABLE_PRODUCTS . &#8221; p left join &#8221; . TABLE_MANUFACTURERS . &#8221; m using(manufacturers_id) left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id, &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_CATEGORIES . &#8221; c, &#8221; . TABLE_PRODUCTS_TO_CATEGORIES . &#8221; p2c&#8221;;<\/p>\n<p>if ( (DISPLAY_PRICE_WITH_TAX == &#8216;true&#8217;) &amp;&amp; (tep_not_null($pfrom) || tep_not_null($pto)) ) {<br \/>\nif (!tep_session_is_registered(&#8216;customer_country_id&#8217;)) {<br \/>\n$customer_country_id = STORE_COUNTRY;<br \/>\n$customer_zone_id = STORE_ZONE;<br \/>\n}<br \/>\n$from_str .= &#8221; left join &#8221; . TABLE_TAX_RATES . &#8221; tr on p.products_tax_class_id = tr.tax_class_id left join &#8221; . TABLE_ZONES_TO_GEO_ZONES . &#8221; gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = &#8216;0&#8217; or gz.zone_country_id = &#8216;&#8221; . (int)$customer_country_id . &#8220;&#8216;) and (gz.zone_id is null or gz.zone_id = &#8216;0&#8217; or gz.zone_id = &#8216;&#8221; . (int)$customer_zone_id . &#8220;&#8216;)&#8221;;<br \/>\n}<\/p>\n<p>$where_str = &#8221; where p.products_status = &#8216;1&#8217; and p.products_id = pd.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id &#8220;;<\/p>\n<p>to:<\/p>\n<p>$from_str = &#8220;from &#8221; . TABLE_PRODUCTS . &#8221; p left join &#8221; . TABLE_MANUFACTURERS . &#8221; m using(manufacturers_id) left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id&#8221;;<\/p>\n<p>if ( (DISPLAY_PRICE_WITH_TAX == &#8216;true&#8217;) &amp;&amp; (tep_not_null($pfrom) || tep_not_null($pto)) ) {<br \/>\nif (!tep_session_is_registered(&#8216;customer_country_id&#8217;)) {<br \/>\n$customer_country_id = STORE_COUNTRY;<br \/>\n$customer_zone_id = STORE_ZONE;<br \/>\n}<br \/>\n$from_str .= &#8221; left join &#8221; . TABLE_TAX_RATES . &#8221; tr on p.products_tax_class_id = tr.tax_class_id left join &#8221; . TABLE_ZONES_TO_GEO_ZONES . &#8221; gz on tr.tax_zone_id = gz.geo_zone_id and (gz.zone_country_id is null or gz.zone_country_id = &#8216;0&#8217; or gz.zone_country_id = &#8216;&#8221; . (int)$customer_country_id . &#8220;&#8216;) and (gz.zone_id is null or gz.zone_id = &#8216;0&#8217; or gz.zone_id = &#8216;&#8221; . (int)$customer_zone_id . &#8220;&#8216;)&#8221;;<br \/>\n}<\/p>\n<p>$from_str .= &#8220;, &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_CATEGORIES . &#8221; c, &#8221; . TABLE_PRODUCTS_TO_CATEGORIES . &#8221; p2c&#8221;;<\/p>\n<p>$where_str = &#8221; where p.products_status = &#8216;1&#8217; and p.products_id = pd.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id &#8220;;<\/p>\n<p><strong><a title=\"idx\" name=\"idx\"><\/a>INDEX.PHP<\/strong><\/p>\n<p><strong>Solution:\u00a0<\/strong>The following lines must be replaced in catalog\/<strong>index.php<\/strong>:<\/p>\n<p>Line 175, from:<\/p>\n<p>$listing_sql = &#8220;select &#8221; . $select_column_list . &#8221; 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 &#8221; . TABLE_PRODUCTS . &#8221; p, &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_MANUFACTURERS . &#8221; m, &#8221; . TABLE_PRODUCTS_TO_CATEGORIES . &#8221; p2c left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id where p.products_status = &#8216;1&#8217; and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = &#8216;&#8221; . (int)$HTTP_GET_VARS[&#8216;manufacturers_id&#8217;] . &#8220;&#8216; and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p2c.categories_id = &#8216;&#8221; . (int)$HTTP_GET_VARS[&#8216;filter_id&#8217;] . &#8220;&#8216;&#8221;;<\/p>\n<p>to:<\/p>\n<p>$listing_sql = &#8220;select &#8221; . $select_column_list . &#8221; 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 &#8221; . TABLE_PRODUCTS . &#8221; p left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id, &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_MANUFACTURERS . &#8221; m, &#8221; . TABLE_PRODUCTS_TO_CATEGORIES . &#8221; p2c where p.products_status = &#8216;1&#8217; and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = &#8216;&#8221; . (int)$HTTP_GET_VARS[&#8216;manufacturers_id&#8217;] . &#8220;&#8216; and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p2c.categories_id = &#8216;&#8221; . (int)$HTTP_GET_VARS[&#8216;filter_id&#8217;] . &#8220;&#8216;&#8221;;<\/p>\n<p>Line 178, from:<\/p>\n<p>$listing_sql = &#8220;select &#8221; . $select_column_list . &#8221; 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 &#8221; . TABLE_PRODUCTS . &#8221; p, &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_MANUFACTURERS . &#8221; m left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id where p.products_status = &#8216;1&#8217; and pd.products_id = p.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = &#8216;&#8221; . (int)$HTTP_GET_VARS[&#8216;manufacturers_id&#8217;] . &#8220;&#8216;&#8221;;<\/p>\n<p>to:<\/p>\n<p>$listing_sql = &#8220;select &#8221; . $select_column_list . &#8221; 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 &#8221; . TABLE_PRODUCTS . &#8221; p left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id, &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_MANUFACTURERS . &#8221; m where p.products_status = &#8216;1&#8217; and pd.products_id = p.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = &#8216;&#8221; . (int)$HTTP_GET_VARS[&#8216;manufacturers_id&#8217;] . &#8220;&#8216;&#8221;;<\/p>\n<p>Line 184, from:<\/p>\n<p>$listing_sql = &#8220;select &#8221; . $select_column_list . &#8221; 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 &#8221; . TABLE_PRODUCTS . &#8221; p, &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_MANUFACTURERS . &#8221; m, &#8221; . TABLE_PRODUCTS_TO_CATEGORIES . &#8221; p2c left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id where p.products_status = &#8216;1&#8217; and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = &#8216;&#8221; . (int)$HTTP_GET_VARS[&#8216;filter_id&#8217;] . &#8220;&#8216; and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p2c.categories_id = &#8216;&#8221; . (int)$current_category_id . &#8220;&#8216;&#8221;;<\/p>\n<p>to:<\/p>\n<p>$listing_sql = &#8220;select &#8221; . $select_column_list . &#8221; 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 &#8221; . TABLE_PRODUCTS . &#8221; p left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id, &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_MANUFACTURERS . &#8221; m, &#8221; . TABLE_PRODUCTS_TO_CATEGORIES . &#8221; p2c where p.products_status = &#8216;1&#8217; and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = &#8216;&#8221; . (int)$HTTP_GET_VARS[&#8216;filter_id&#8217;] . &#8220;&#8216; and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p2c.categories_id = &#8216;&#8221; . (int)$current_category_id . &#8220;&#8216;&#8221;;<\/p>\n<p>Line 187, from:<\/p>\n<p>$listing_sql = &#8220;select &#8221; . $select_column_list . &#8221; 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 &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_PRODUCTS . &#8221; p left join &#8221; . TABLE_MANUFACTURERS . &#8221; m on p.manufacturers_id = m.manufacturers_id, &#8221; . TABLE_PRODUCTS_TO_CATEGORIES . &#8221; p2c left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id where p.products_status = &#8216;1&#8217; and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p2c.categories_id = &#8216;&#8221; . (int)$current_category_id . &#8220;&#8216;&#8221;;<\/p>\n<p>to:<\/p>\n<p>$listing_sql = &#8220;select &#8221; . $select_column_list . &#8221; 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 &#8221; . TABLE_PRODUCTS_DESCRIPTION . &#8221; pd, &#8221; . TABLE_PRODUCTS . &#8221; p left join &#8221; . TABLE_MANUFACTURERS . &#8221; m on p.manufacturers_id = m.manufacturers_id left join &#8221; . TABLE_SPECIALS . &#8221; s on p.products_id = s.products_id, &#8221; . TABLE_PRODUCTS_TO_CATEGORIES . &#8221; p2c where p.products_status = &#8216;1&#8217; and p.products_id = p2c.products_id and pd.products_id = p2c.products_id and pd.language_id = &#8216;&#8221; . (int)$languages_id . &#8220;&#8216; and p2c.categories_id = &#8216;&#8221; . (int)$current_category_id . &#8220;&#8216;&#8221;;<br \/>\n<strong><a title=\"cats\" name=\"cats\"><\/a>ADMIN\/CATEGORIES.PHP<\/strong><\/p>\n<p><strong>Solution:\u00a0<\/strong>Line 292 in catalog<strong>\/admin\/categories.php<\/strong>\u00a0must be changed from:<\/p>\n<p>tep_db_query(&#8220;insert into &#8221; . TABLE_PRODUCTS . &#8221; (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 (&#8216;&#8221; . tep_db_input($product[&#8216;products_quantity&#8217;]) . &#8220;&#8216;, &#8216;&#8221; . tep_db_input($product[&#8216;products_model&#8217;]) . &#8220;&#8216;, &#8216;&#8221; . tep_db_input($product[&#8216;products_image&#8217;]) . &#8220;&#8216;, &#8216;&#8221; . tep_db_input($product[&#8216;products_price&#8217;]) . &#8220;&#8216;, now(), &#8216;&#8221; . tep_db_input($product[&#8216;products_date_available&#8217;]) . &#8220;&#8216;, &#8216;&#8221; . tep_db_input($product[&#8216;products_weight&#8217;]) . &#8220;&#8216;, &#8216;0&#8217;, &#8216;&#8221; . (int)$product[&#8216;products_tax_class_id&#8217;] . &#8220;&#8216;, &#8216;&#8221; . (int)$product[&#8216;manufacturers_id&#8217;] . &#8220;&#8216;)&#8221;);<\/p>\n<p>to:<\/p>\n<p>tep_db_query(&#8220;insert into &#8221; . TABLE_PRODUCTS . &#8221; (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 (&#8216;&#8221; . tep_db_input($product[&#8216;products_quantity&#8217;]) . &#8220;&#8216;, &#8216;&#8221; . tep_db_input($product[&#8216;products_model&#8217;]) . &#8220;&#8216;, &#8216;&#8221; . tep_db_input($product[&#8216;products_image&#8217;]) . &#8220;&#8216;, &#8216;&#8221; . tep_db_input($product[&#8216;products_price&#8217;]) . &#8220;&#8216;, now(), &#8221; . (empty($product[&#8216;products_date_available&#8217;]) ? &#8220;null&#8221; : &#8220;&#8216;&#8221; . tep_db_input($product[&#8216;products_date_available&#8217;]) . &#8220;&#8216;&#8221;) . &#8220;, &#8216;&#8221; . tep_db_input($product[&#8216;products_weight&#8217;]) . &#8220;&#8216;, &#8216;0&#8217;, &#8216;&#8221; . (int)$product[&#8216;products_tax_class_id&#8217;] . &#8220;&#8216;, &#8216;&#8221; . (int)$product[&#8216;manufacturers_id&#8217;] . &#8220;&#8216;)&#8221;);<\/p>\n<p>The following SQL queries need to be performed:<\/p>\n<p>ALTER TABLE whos_online MODIFY COLUMN last_page_url VARCHAR(255) NOT NULL;<\/p>\n<p>ALTER TABLE customers MODIFY COLUMN customers_default_address_id INTEGER;<\/p>\n<p>ALTER TABLE customers_basket MODIFY COLUMN final_price DECIMAL(15,4);<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Upgrading the servers to MySQL ver.5 often results in breaking working osCommerce sites.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/41"}],"collection":[{"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":1,"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":42,"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions\/42"}],"wp:attachment":[{"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/edynamo.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}