Trying to run SBA 1.5.4 for [ZC 1.5.8][PHP 8.0]
Few remarks for some errors in admin/products_with_attributes_stock page.
First it gives the following error
--> PHP Fatal error: 1064:You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 0, 1' at line 1
In admin/includes/classes/products_with_attributes_stock.php
on around line 376:
PHP Code:
$query_products = "SELECT DISTINCT " . $retFieldsTxt . ((empty($search_order_by_fields) || empty($retFieldsTxt)) ? '' : ', ') . $search_order_by_fields . "
FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa
INNER JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON (pa.products_id = pd.products_id)
INNER JOIN " . TABLE_PRODUCTS . " p ON (pa.products_id = p.products_id)
WHERE
pd.language_id=" . (int)$language_id . "
" . $w . "
ORDER BY " . $search_order_by;
// . $SearchRange; // zamzom: Took it out, because splitPageResults adds another LIMIT which triggers MySql error
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);
}
$SearchRange already carries a MySql LIMIT statement, however a consequtively coming call to splitPageResults adds another LIMIT statement so this triggers an error. I think the first $SearchRange can be ommited?
Secondly, search does not function. It seems earlier search parameter was input through a Get statement (in admin/products_with_attributes_stock.php) however in the latest it was converted to a Post method. Nevertheless again in admin/includes/classes/products_with_attributes_stock.php around line 277
PHP Code:
if (isset($_GET['search']) && $_GET['search']) { // mc12345678 Why was $_GET['search'] omitted?
$s = zen_db_input($_GET['search']);
//$w = "(p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '%$s%') AND " ;//original version of search
//$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' OR p.products_model LIKE '$s%' ) AND " ;//changed search to products_model 'startes with'.
//$w = "( p.products_id = '$s' OR d.products_name LIKE '%$s%' ) AND " ;//removed products_model from search
$w = " AND ( p.products_id = '$s'
OR d.products_name LIKE '%$s%'
OR p.products_model LIKE '%$s%'
OR p.products_id
IN (SELECT products_id
FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
WHERE pwas.customid
LIKE '%$s%')
) "; //changed search to products_model 'starts with'.
}
//Show last edited record or Limit number of records displayed on page
$SearchRange = null;
if (isset($ReturnedProductID) && !isset($_GET['search'])) {
$ReturnedProductID = zen_db_input($ReturnedProductID);
//$w = "( p.products_id = '$ReturnedProductID' ) AND " ;//sets returned record to display
$w = " AND ( p.products_id = '$ReturnedProductID' ) " ;//sets returned record to display
if (empty($_GET['products_filter']) || $_GET['products_filter'] < 0) {
$SearchRange = "LIMIT 1";//show only selected record
}
Get statements are used and these don't get anything

I think all of the $_GET['search'] should be replaced by $_POST['search']
also there is an error with the $w assignment, the tag for product description table should be pd instead of d, again around line 282:
PHP Code:
$w = " AND ( p.products_id = '$s'
OR pd.products_name LIKE '%$s%'
OR p.products_model LIKE '%$s%'
OR p.products_id
IN (SELECT products_id
FROM " . TABLE_PRODUCTS_WITH_ATTRIBUTES_STOCK . " pwas
WHERE pwas.customid
LIKE '%$s%')
) "; //changed search to products_model 'starts with'.
Bookmarks