Zen Cart Logo
Forums / General Questions / PHP Fatal error: 1109: Unknown table 'p' in field list

PHP Fatal error: 1109: Unknown table 'p' in field list

Views: 4,410

Results 21 to 25 of 25
18 Jan 2017, 8:51 PM
#21
answer_42 avatar

answer_42

Zen Follower

Join Date:
Dec 2016
Location:
Washington
Posts:
109
Plugin Contributions:
0

PHP Fatal error: 1109: Unknown table 'p' in field list

I did some more searching and found this post https://www.zen-cart.com/showthread.php?121420-1109-Unknown-table-p-in-field-list-on-Featured-and-All-prods-listings

In post#10 it was suggested to "Try temporarily changing the extension on tpl_products_all_default.php to .tmp and see what effect that has.

(I don't recommend this as a permanent solution and at some stage it should be renamed back if it's needed or deleted if it's not) "

With the change to the .tmp file extension the page showed correctly without any errors

18 Jan 2017, 9:50 PM
#22
carlwhat avatar

carlwhat

zennedOut

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

Re: PHP Fatal error: 1109: Unknown table 'p' in field list

all that change does is remove the part of the winchester_responsive template that is not working. which you can do, but it does not solve the problem.

we have been a bit on the wrong track, as some things are making a little more sense.

i think if you replace the:

includes/classes/split_page_results.php

with the v1.5.1 version contained in the winchester_responsive download, things would probably start working. must be a reason why she has that old version there as her construct of the $listing_sql must be old as well...

if you wanted to continue debugging why this is the way it is, we can look at the $listing_sql.

in

includes/modules/winchester_responsive/product_listing.php

right above line 35 add:

echo 'LISTING SQL: ' . $listing_sql;

and post the results of that. it should display on the screen...

i am sorry i did not see it earlier. (it is also listed in your debug log above somewhere previous in this thread...)

turn the other debug off.

19 Jan 2017, 3:04 PM
#23
answer_42 avatar

answer_42

Zen Follower

Join Date:
Dec 2016
Location:
Washington
Posts:
109
Plugin Contributions:
0

Re: PHP Fatal error: 1109: Unknown table 'p' in field list

I changed the file extensions back to .php and I replaced the includes/classes/split_page_results.php with the 1.5.1 version , the results were the same displaying "WARNING: An Error occurred, please refresh the page and try again."
I added echo 'LISTING SQL: ' . $listing_sql; right above line 35 in:includes/modules/winchester_responsive/product_listing.php and it displayed an empty variable LISTING SQL:

19 Jan 2017, 9:11 PM
#24
carlwhat avatar

carlwhat

zennedOut

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

Re: PHP Fatal error: 1109: Unknown table 'p' in field list

ok, a few things:

#1, i would post in the support group for winchester_responsive. in general, i do not help with picaflor templates due to my own personal biases.
#2, what you have posted makes sense. your original error was:

PHP Fatal error:  1109:Unknown table 'p' in field list :: select count(p.products_id) as total 

if $listing_sql is empty, then this line:

$listing_split = new splitPageResults($listing_sql, $max_results, 'p.products_id', 'page');

will create the sql statement that is erroring out, ie:

select count(p.products_id) as total 

#3 it looks like you have not successfully implemented this template. you must have includes/modules/pages for the 4 pages that are erroring from the ZC base as opposed to winchester_responsive template files. for example, for:

includes/modules/pages/products_all/header_php.php

the code should look like:

<?php
/**Single Listing Template mod v1.8
 * products_all  header_php.php
 *
 * @package page
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: header_php.php 6912 2007-09-02 02:23:45Z drbyte $
 */

  require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));



  $breadcrumb->add(NAVBAR_TITLE);
// display order dropdown
  $disp_order_default = PRODUCT_ALL_LIST_SORT_DEFAULT;
  require(DIR_WS_MODULES . zen_get_module_directory(FILENAME_LISTING_DISPLAY_ORDER));

  $products_all_array = array();

  $listing_sql = "SELECT p.products_type, p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id,
                                    p.products_date_added, m.manufacturers_name, p.products_model, p.products_quantity, p.products_weight, p.product_is_call,
                                    p.product_is_always_free_shipping, p.products_qty_box_status,
                                    p.master_categories_id, m.manufacturers_id
                             FROM " . TABLE_PRODUCTS . " p
                             LEFT JOIN " . TABLE_MANUFACTURERS . " m ON (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd
                             WHERE p.products_status = 1
                             AND p.products_id = pd.products_id
                             AND pd.language_id = :languageID " . $order_by;

  $listing_sql = $db->bindVars($listing_sql, ':languageID', $_SESSION['languages_id'], 'integer');
  //check to see if we are in normal mode ... not showcase, not maintenance, etc
  $show_submit = zen_run_normal();

$define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL,
  'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME,
  'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER,
  'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE,
  'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY,
  'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT,
  'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE);

  /*                         ,
  'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW);
  */
  asort($define_list);
  reset($define_list);
  $column_list = array();
  foreach ($define_list as $key => $value)
  {
    if ($value > 0) $column_list[] = $key;
  }
?>

i'm guessing yours does not. this is where the $listing_sql variable gets set.

i would pay close attention to the install and ensuring you have all of the correct files in the correct place.

best.

20 Jan 2017, 5:06 PM
#25
answer_42 avatar

answer_42

Zen Follower

Join Date:
Dec 2016
Location:
Washington
Posts:
109
Plugin Contributions:
0

Re: PHP Fatal error: 1109: Unknown table 'p' in field list

You were correct; I looked at the includes/modules/pages/page-throwing-error/header.php files and they

were using the ZC base as opposed to winchester_responsive template files. I changed the files

and the pages no longer error out.

Unfortunately, I traced the change in these files all the way back to when I upgraded from v1.5.1 to

v1.5.5d. I assumed that it was just a PEBKAC error, but looking back into the myDEBUG logs, I see that

there were Zen cart install errors as well.

MySQL error 1292 encountered during zc_install:

MySQL error 1067 encountered during zc_install:

MySQL error 1062 encountered during zc_install:

I think my best choice is to upgrade the v1.5.1 again instead of attempting to fix these errors. Who knows

what else could be wrong.

Thank you again for all of your help.