Jump to content

Recommended Posts

if ( is_array($color_asked) && count($color_asked) == 3 ) { 

Or,....

if ( is_countable($color_asked) && count($color_asked) == 3 ) { 

 

 


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites
10 minutes ago, Demitry said:

if ( is_array($color_asked) && count($color_asked) == 3 ) { 

Or,....

if ( is_countable($color_asked) && count($color_asked) == 3 ) { 

 

 

tried both, and they both give:

Parse error: syntax error, unexpected '' (T_STRING)

Share this post


Link to post
Share on other sites

That's usually an error where there's either an extra single quotation mark, or a missing one. It should not have anything to do with the IF statement.

If you are using a code editor, it will usually point to the line that is causing the T_STRING error.

 

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites
24 minutes ago, Demitry said:

That's usually an error where there's either an extra single quotation mark, or a missing one. It should not have anything to do with the IF statement.

If you are using a code editor, it will usually point to the line that is causing the T_STRING error.

 

	function SetRgbColor($color_asked) {
		//Returns an array in R,G,B format 0-255
		if ($color_asked == "") { $color_asked = array(0,0,0); };
		
		if ( is_countable($color_asked) && count($color_asked) == 3 ) {
		#if ( count($color_asked) == 3 ) { //already array of 3 rgb 
	   		$ret_val =  $color_asked;
		} else { // is asking for a color by string
			if(substr($color_asked,0,1) == "#") {  //asking in #FFFFFF format. 
				$ret_val =  array(hexdec(substr($color_asked,1,2)), hexdec(substr($color_asked,3,2)), hexdec(substr($color,5,2)));
			} else { 
				$ret_val =  $this->rgb_array[$color_asked];
			}
		}
		return $ret_val;
	}

Is it working on your side?

Share this post


Link to post
Share on other sites

I don't have your version set up and don't use banner manager. I ran into similar count() function errors when migrating to PHP7.3

You should probably use the is_array() function because in the statement just above, the variable is set to an array.

 

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites
13 minutes ago, Demitry said:

I don't have your version set up and don't use banner manager. I ran into similar count() function errors when migrating to PHP7.3

 

 

	function SetRgbColor($color_asked) {
		//Returns an array in R,G,B format 0-255
		if ($color_asked == "") { $color_asked = array(0,0,0); }
		
		if ( is_array($color_asked) ) {
			if ( count($color_asked) == 3 ) { $ret_val = $color_asked; }
		} else { // is asking for a color by string
			if(substr($color_asked,0,1) == "#") {  //asking in #FFFFFF format. 
				$ret_val =  array(hexdec(substr($color_asked,1,2)), hexdec(substr($color_asked,3,2)), hexdec(substr($color,5,2)));
			} else { 
				$ret_val =  $this->rgb_array[$color_asked];
			}
		}
		return $ret_val;
	}

This clears the error.

Share this post


Link to post
Share on other sites

You can add

 isset($entry_zone_id) && 

to line 168 and line 181, as in,...

if (isset($entry_zone_id) && $entry_zone_id > 0) 

That should get rid of the error, but you still need to test the functionality to make sure it works with this change. I'm not sure why it's throwing this error.

 

 


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites

if i put this on 168:

        if (isset($entry_zone_id)) {
			if ($entry_zone_id > 0) $entry_state = '';
		}

and on 184

        if (isset($entry_zone_id)) {
          if ($entry_zone_id > 0) {
            $sql_data_array['entry_zone_id'] = $entry_zone_id;
            $sql_data_array['entry_state'] = '';
          } else {
            $sql_data_array['entry_zone_id'] = '0';
            $sql_data_array['entry_state'] = $entry_state;
          }
		}
        }

then the errors are cleared. Not sure if its the best way to do it though.

 

 

 

 

Share this post


Link to post
Share on other sites

Right! That is why I said that you have to test the functionality for that state function/feature.

All that isset() function does is check to see if the variable was previously set. In other words, if it wasn't set, the instructions that follow in those two IF statements will not execute.

 

 

Edited by Demitry

osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites

admin/includes/functions/general.php

  function tep_get_products_name($product_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);

    return $product['products_name'];
  }

Warning: Trying to access array offset on value of type null 

  function tep_get_products_name($product_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);

    if (isset($product['products_name'])) return $product['products_name'];
  }

This clears the error.

Share this post


Link to post
Share on other sites
  function tep_get_products_name($product_id, $language_id = 0) {
    global $languages_id;

    if ($language_id == 0) $language_id = $languages_id;
    $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);

	return isset($product['products_name']) ? $product['products_name'] : '';
  }

  function tep_get_products_description($product_id, $language_id) {
    $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
    $product = tep_db_fetch_array($product_query);

	return isset($product['products_description']) ? $product['products_description'] : '';
  }

 

Share this post


Link to post
Share on other sites

admin/functions/general.php

tep_generate_category_path function

there are 2x Warning: Trying to access array offset on value of type null

these are the 2 lines that trigger the warnings:

      $categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']);
      if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);

 

Share this post


Link to post
Share on other sites
2 hours ago, Hotclutch said:

admin/functions/general.php

tep_generate_category_path function

there are 2x Warning: Trying to access array offset on value of type null

these are the 2 lines that trigger the warnings:


      $categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']);
      if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);

 

$categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);
if ((!empty($category['parent_id'])) && ($category['parent_id'] != '0')) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);

 


The water in a vessel is sparkling; the water in the sea is dark. The small truth has words which are clear; the great truth has great silence.

- Rabindranath Tagore

Share this post


Link to post
Share on other sites

from Zombie Phoenix v1.0.7.3

 

  function tep_generate_category_path($id, $from = 'category', $categories_array = [], $index = 0) {
    global $languages_id;

    if ($from == 'product') {
      $categories_query = tep_db_query("SELECT categories_id FROM products_to_categories WHERE products_id = " . (int)$id);
      while ($categories = tep_db_fetch_array($categories_query)) {
        if ($categories['categories_id'] == '0') {
          $categories_array[$index][] = ['id' => '0', 'text' => TEXT_TOP];
        } else {
          $category_query = tep_db_query("SELECT cd.categories_name, c.parent_id FROM categories c, categories_description cd WHERE c.categories_id = " . (int)$categories['categories_id'] . " AND c.categories_id = cd.categories_id AND cd.language_id = " . (int)$languages_id);
          $category = tep_db_fetch_array($category_query);
          $categories_array[$index][] = ['id' => $categories['categories_id'], 'text' => $category['categories_name']];
          if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) {
            $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
          }
          $categories_array[$index] = array_reverse($categories_array[$index]);
        }
        $index++;
      }
    } elseif ($from == 'category') {
      $category_query = tep_db_query("SELECT cd.categories_name, c.parent_id FROM categories c, categories_description cd WHERE c.categories_id = " . (int)$id . " AND c.categories_id = cd.categories_id AND cd.language_id = " . (int)$languages_id);
      $category = tep_db_fetch_array($category_query);
      $categories_array[$index][] = ['id' => $id, 'text' => $category['categories_name']];
      if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) {
        $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
      }
    }

    return $categories_array;
  }

 

 


osCommerce: made for programmers, ...because store owners do not want to be programmers.

https://trends.google.com/trends/explore?date=all&geo=US&q=oscommerce

Share this post


Link to post
Share on other sites
10 hours ago, Smoky Barnable said:

$categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);
if ((!empty($category['parent_id'])) && ($category['parent_id'] != '0')) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);

 

Here is how to trigger these errors:

In Admin go to products_expected.php -> if there are none you won't notice any errors and you will be unaware they exist in the code.

Now go set a future available date on one of the products.

Go back to products_expected.php, and try to edit from there. You will see the errors.

@Smoky Barnable

      if ((!empty($category['parent_id'])) && ($category['parent_id'] != '0')) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);

this line of code fixes one of the errors, still leaves the other.

$categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);

this line of code throws more errors, not sure if you meant to put $categories['categories_id'] or $category['categories_id'] instead.

Share this post


Link to post
Share on other sites

Sloppy Words Cleaner throws these errors:

zzzz-min.png.98884d204ffe52e1a0c35b6c5674f3d4.png

To be safe i put isset on all the variables

    // BOF Sloppy Words Cleaner
    // note: rem // any below lines that you don't want to clean (or) maybe don't have, you can look at your existing osC input fields, line ~50)
    $firstname = isset($firstname) ? RemoveShouting($firstname,true) : '';
    $lastname = isset($lastname) ? RemoveShoutingLN($lastname,true) : '';
    $email_address = isset($email_address) ? strtolower($email_address) : '';
    $confirm_email_address = isset($confirm_email_address) ? strtolower($confirm_email_address) : '';
    //$company = RemoveShoutingCN($company);
    $street_address = isset($street_address) ? RemoveShouting($street_address) : '';
    $street_address2 = isset($street_address2) ? RemoveShouting($street_address2) : '';
    $suburb = isset($suburb) ? RemoveShouting($suburb) : '';
    $postcode = isset($postcode) ? strtoupper($postcode) : '';
    $city = isset($city) ? RemoveShouting($city) : '';
    $state = isset($state) ? RemoveShouting($state) : '';
    // EOF Sloppy Words Cleaner 

 

Share this post


Link to post
Share on other sites

zz2-min.png.2f087685a40df8c8a728af1bc2ed02f0.png

      $wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
  function tep_update_whos_online() {
    global $customer_id;

    if (tep_session_is_registered('customer_id')) {
      $wo_customer_id = $customer_id;

      $customer_query = tep_db_query("select customers_firstname, customers_lastname from customers where customers_id = '" . (int)$customer_id . "'");
      $customer = tep_db_fetch_array($customer_query);

      $wo_full_name = $customer['customers_firstname'] . ' ' . $customer['customers_lastname'];
    } else {
      $wo_customer_id = '';
      $wo_full_name = 'Guest';
    }

 

Share this post


Link to post
Share on other sites

On the products_attributes.php an error pointing to admin/includes/functions/general.php
Warning: Trying to access array offset on value of type null

  function tep_options_name($options_id) {
    global $languages_id;

    $options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'");
    $options_values = tep_db_fetch_array($options);

    return $options_values['products_options_name'];
  }

This clears the error:

  function tep_options_name($options_id) {
    global $languages_id;

    $options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$languages_id . "'");
    $options_values = tep_db_fetch_array($options);

    return $options_values['products_options_name'] ?? '';
  }

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×