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

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

×