Forums / General Questions / 1109 Unknown table 'p' in field list

1109 Unknown table 'p' in field list

Started by dexter71 on 12 Sep 2013, 4:39 PM · Views: 1,164

Results 1 to 3 of 3
12 Sep 2013, 4:39 PM
#1
dexter71 avatar

dexter71

New Zenner

Join Date:
Sep 2013
Location:
Norway
Posts:
3
Plugin Contributions:
0

1109 Unknown table 'p' in field list

I’m using Zen Cart 1.39h and have problems with displaying the specials function. I’m also using a template..

http://masked/index.php?main_page=specials

Attachment 13058
I’ve enabled logging on MySQL and extracted the query in question from general_log.csv :

SELECT p.products_id, p.products_image, pd.products_name, p.master_categories_id
FROM (products p LEFT JOIN specials s on p.products_id = s.products_id LEFT JOIN products_description pd on p.products_id = pd.products_id )
WHERE p.products_id = s.products_id and p.products_id = pd.products_id and p.products_status = '1'
AND s.status = 1
AND pd.language_id = 1
ORDER BY s.specials_date_added DESC limit 12

When I run this query in phpMyAdmin, it runs perfectly:
Attachment 13059

I’m not sure which php-file which is in use when this query is executed on the web, but it seems like something with the query within the php-file malfunctions..
Could anyone please help?

Thanks,
Dex

12 Sep 2013, 5:54 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: 1109 Unknown table 'p' in field list

You're talking about 2 different queries.

The first, with the error, is "SELECT count(p.products_id) as total". Note how it's missing any mention of table names, let alone a tablename alias of "p" to match a table name.

The second query you posted does indeed work correctly, primarily because it's a complete query.

Your first query is probably a pagination check, to see whether controls need to be added to the page to allow the visitor to click to more pages of results.

In a default uncustomized unaltered ZC install, using the original template, the pagination is handled by calls to a split_page_results class object. This involves some PHP code in the template files to determine whether to display the controls, and what part to display. It also involves some PHP code in the corresponding modules/pages files to determine which subset of results are being requested. And then once those pieces are determined it then will run the actual real original query (ie: your 2nd one) to extract the actual results.

So, your symptoms could be a result of many things, including but not limited to:

  • someone has tampered with the split_page_results class
  • someone has altered the code in the modules/pages/specials/ files (you said this was happening on the specials page)
  • someone has altered the code in the template files related to specials (or whatever templates are involved in whatever page you're getting the error on)
  • plugins you've installed

.
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.

12 Sep 2013, 6:11 PM
#3
dexter71 avatar

dexter71

New Zenner

Join Date:
Sep 2013
Location:
Norway
Posts:
3
Plugin Contributions:
0

Re: 1109 Unknown table 'p' in field list

Thanks for the reply DrByte. I think you put me on the right path :smile:. I replaced the tpl_specials_default.php in my template with the original file, and it seems to have done the trick! I'll just check it further and get back here if I have any follow-up questions.