Page 1 of 1

Updating some old code

Posted: Sun Dec 08, 2024 1:58 pm
by tessthepup
Good afternoon everyone,

I feel like a first time poster again as it has been a while as life has been so hectic this year ;)

I wonder if anyone can help to shed a light on how to resolve this error
PHP Warning: mysqli_result::fetch_assoc() expects exactly 0 parameters, 1 given in
The line of code in question is this

Code: Select all

$category = $category_query->fetch_assoc($category_query);
and this is the full function

Code: Select all

function tep_get_product_path($products_id) {
    $cPath = '';

    $category_query = $GLOBALS['db']->query("select p2c.categories_id from products p, products_to_categories p2c where p.products_id = '" . (int)$products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id limit 1");
    if (mysqli_num_rows($category_query)) {
      
      $category = $category_query->fetch_assoc($category_query);
      
      $categories = array();
      tep_get_parent_categories($categories, $category['categories_id']);

      $categories = array_reverse($categories);

      $cPath = implode('_', $categories);

      if (!Text::is_empty($cPath)) $cPath .= '_';
      $cPath .= $category['categories_id'];
    }

    return $cPath;
  }
Thanks

Mark

Re: Updating some old code

Posted: Sun Dec 08, 2024 2:06 pm
by burt

Code: Select all

$category = $category_query->fetch_assoc();
Exp:

$category = $category_query->fetch_assoc($category_query);

The bit in bold is a parameter.
fetch_assoc requires *no* parameters.
Answer: remove the parameter.

Re: Updating some old code

Posted: Sun Dec 08, 2024 2:09 pm
by tessthepup
burt wrote: Sun Dec 08, 2024 2:06 pm

Code: Select all

$category = $category_query->fetch_assoc();
Exp:

$category = $category_query->fetch_assoc($category_query);

The bit in bold is a parameter.
fetch_assoc requires *no* parameters.
Answer: remove the parameter.
Thank you Gary much appreciated :+1:

Onto the next error (I maybe back) lol

Re: Updating some old code

Posted: Sun Dec 08, 2024 2:27 pm
by tessthepup
as I thought not sure about the changes to these lines as either

Code: Select all

<div class="mt-2 ml-auto"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_REQUEST['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID', 'action'))); ?></div>
specifically the tep_get_all_get_params part

and also this error is being produced
PHP Notice: Trying to access array offset on value of type null in
from this line

Code: Select all

<h3><?php echo HEADING_TITLE ." ".$partscat_row['category_name']; ?></h3>
I believe it has something to do with this code

Code: Select all

if(isset($_REQUEST['parts_category_id'])&&($_REQUEST['parts_category_id']!='')) {
   $partscat_query = $GLOBALS['db']->query("SELECT * FROM parts_category WHERE parts_category_id = '".$_REQUEST['parts_category_id']."'");
   $partscat_row = $partscat_query->fetch_assoc();
  }

Re: Updating some old code

Posted: Tue Dec 10, 2024 12:35 pm
by tessthepup
Hi,

I have so far managed to solve most of the errors thrown my way however this one is still eluding me
PHP Deprecated: The tep_get_all_get_params function has been deprecated. in

Code: Select all

<?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_REQUEST['page'], tep_get_all_get_params(array('page', 'info', 'x', 'y', 'cID', 'action'))); ?>
Thanks

Mark

Re: Updating some old code

Posted: Tue Dec 10, 2024 4:15 pm
by ecartz
Try just removing the call.

Code: Select all

<?= $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_REQUEST['page']) ?>
If that doesn't work, create a link with retain_query_except and pass the parameters from the link to display_links.

Re: Updating some old code

Posted: Tue Dec 10, 2024 5:58 pm
by tessthepup
ecartz wrote: Tue Dec 10, 2024 4:15 pm Try just removing the call.

Code: Select all

<?= $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_REQUEST['page']) ?>
If that doesn't work, create a link with retain_query_except and pass the parameters from the link to display_links.
@ecartz
Thank you very much it worked :+1: