If this is your first visit, check our documentation. To post, register or login.
Forums / Code Matters / Bug Reports / PHP Fatal error: 1060:Duplicate column name 'products_id'

PHP Fatal error: 1060:Duplicate column name 'products_id'

Locked

Started by jodean on 22 Jul 2023, 9:54 PM · Views: 1,527

Results 1 to 10 of 10
This thread is locked. New replies are disabled.
22 Jul 2023, 9:54 PM
#1
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

Post #1 by jodean

[Note: remember to include site URL, ZC version, list of plugins, PHP version, etc ... read the Posting Tips shown above for information to include in your post here.
And, remove this comment before actually posting!]

I recently upgraded from 1.5.7 to 1.5.8 and started receiving the following error whenever a search is done in SBA Search. I went back to 1.5.7 and it did not have the error. Then I tried upgrading for the second time with new douwn loads etc. and the error repeated. It appears the error is in 1.5.8.

Has anyone else experienced the error?

SBA Error
Product ID Search

[21-Jul-2023 21:20:31 UTC] Request URI: /shop_new/flinG-zvG-sKips/index.php?cmd=products_with_attributes_stock&page=1&search_order_by=products_id, IP address: 69.137.114.242, Language id 1
#1 trigger_error() called at [/includes/classes/db/mysql/query_factory.php:667]
#2 queryFactory->show_error() called at [/includes/classes/db/mysql/query_factory.php:634]
#3 queryFactory->set_error() called at [/includes/classes/db/mysql/query_factory.php:275]
#4 queryFactory->Execute() called at [/flinG-zvG-sKips/includes/classes/split_page_results.php:220]
#5 splitPageResults->numberRows() called at [/flinG-zvG-sKips/includes/classes/split_page_results.php:131]
#6 splitPageResults->__construct() called at [/flinG-zvG-sKips/includes/classes/products_with_attributes_stock.php:389]
#7 products_with_attributes_stock->displayFilteredRows() called at [/flinG-zvG-sKips/products_with_attributes_stock.php:1506]
#8 require(/flinG-zvG-sKips/products_with_attributes_stock.php) called at [/flinG-zvG-sKips/index.php:11]
--> PHP Fatal error: 1060:Duplicate column name 'products_id' :: SELECT count(*) as total FROM (SELECT DISTINCT pa.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_type, p.master_categories_id, p.products_id FROM products_attributes pa INNER JOIN products_description pd ON (pa.products_id = pd.products_id) INNER JOIN products p ON (pa.products_id = p.products_id) WHERE pd.language_id=1 ORDER BY p.products_id ) countresults ==> (as called by) /flinG-zvG-sKips/includes/classes/split_page_results.php on line 220 <== in /includes/classes/db/mysql/query_factory.php on line 667.

22 Jul 2023, 11:35 PM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #3 by swguy

If you look at admin/includes/classes/products_with_attributes_stock.php line 389, you're going to see that it calls numberRows() with a string that looks like this:

SELECT DISTINCT pa.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_type, p.master_categories_id, p.products_id

Just remove the last part (, p.products_id) so it looks like this:

SELECT DISTINCT pa.products_id, pd.products_name, p.products_quantity, p.products_model, p.products_image, p.products_type, p.master_categories_id

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

22 Jul 2023, 11:57 PM
#4
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

Post #4 by jodean

I did not see a line that you are secribing. Here is line 389 and the line before and after.

if (!isset($_GET['seachPID']) && !isset($_GET['pwas-search-button']) && !isset($_GET['updateReturnedPID'])) {
$products_split = new splitPageResults($_GET['page'], STOCK_SET_SBA_NUMRECORDS, $query_products, $products_query_numrows);
}

I do not see a line like you are describing.

23 Jul 2023, 11:12 AM
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #5 by swguy

Search backwards for the definition of $query_products.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

23 Jul 2023, 1:23 PM
#6
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

Post #6 by jodean

swguy:

Search backwards for the definition of $query_products.

I tried looking backwards for the line you are describing and did not find a line with the product id defined twice. I also checked all the select distinct and did not find two definitions for the product id in the same statement.

23 Jul 2023, 1:55 PM
#7
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,974
Plugin Contributions:
8

Post #7 by carlwhat

jodean:

#7 products_with_attributes_stock->displayFilteredRows() called at [/flinG-zvG-sKips/products_with_attributes_stock.php:1506]

i believe this is where your problem lies... not in the classes file.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

23 Jul 2023, 2:40 PM
#8
jodean avatar

jodean

Totally Zenned

Join Date:
May 2011
Location:
Tennessee
Posts:
511
Plugin Contributions:
0

Post #8 by jodean

I am sorry Carl but I do not understand your reply.

23 Jul 2023, 8:42 PM
#9
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Post #9 by mc12345678

This issue ended up being brought up in stock by attributes where a solution has been provided: https://www.zen-cart.com/showthread.php?47180-Stock-by-Attribute-v4-0-addon-for-v1-3-5-1-3-9&p=1396034#post1396034

There are some inherent differences between being able to operate under Zen cart 1.5.7 and 1.5.8 and there have been some changes to Zen cart 1.5.8 requiring other code to be changed, but that's a separate and unrelated topic. While I stated I didn't fully like my provided solution, I have determined a more generic fix that still needs to be uploaded. Of course it would help to hear back that the proposed solution at least worked. It was posted within 3 hours of reporting the here which took 2 hours to post on the appropriate forum thread.

So hey, @jodean, what's the status?

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

23 Jul 2023, 9:17 PM
#10
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,760
Plugin Contributions:
56

Post #10 by swguy

Closing this thread; please continue on SBA thread as noted by @mc12345678.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.