Jump to content



Latest News: (loading..)

- - - - -

Warning: explode() [function.explode]: Empty delimiter

trying to fix this error

  • Please log in to reply
15 replies to this topic

#1   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 19 June 2012 - 12:03 PM

Hi guys,

So I'm getting this error:
Warning: explode() [function.explode]: Empty delimiter in .../includes/classes/currencies.php on line 55

And I just don't understand where it's coming from!
Line 55 says:
$format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);

And also if I use the currencies box to click on the default currency or switch to another currency, this error disappears.    
My default currency is USD and I also have euro and gbp.

Does anybody know what could be the issue here?

#2 ONLINE   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,390 posts
  • Real Name:George Zarkadas
  • Gender:Male
  • Location:Greece

Posted 20 June 2012 - 06:27 AM

Do you have a decimal character (point) entered in admin for the currency that shows the problem? You have to enter something, like a dot or comma

#3   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 20 June 2012 - 06:55 PM

Hi multimixer,

Thanks for replying!
I do have a dot in admin where the decimal point must be inserted....
So that's not the problem..

#4 ONLINE   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,390 posts
  • Real Name:George Zarkadas
  • Gender:Male
  • Location:Greece

Posted 21 June 2012 - 06:29 AM

There is no function explode() in file classes/currencies.php by default

Can you say what version you are using, if you modified that file in any way and place the complete contents of classes/currencies to here?

Please use <> (code tags) for this, like this
This is in code tags


#5   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 21 June 2012 - 06:07 PM

Hi multimixer,

I just checked the vanilla osC classes/currencies.php and sure enough you're right!!
It seems I changed the format function. Mine looks like this now...
I don't remember doing that though.... I'm just going to revert back to the original function...

// class methods
	function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') {
	  global $currency;
	  if (empty($currency_type)) $currency_type = $currency;
	  if ($calculate_currency_value == true) {
			  $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
			  $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
			  $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
			  $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . $format_string[1];
			} else {
			  $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
			  $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
			  $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . $format_string[1];
 
			}								 

	  return $format_string;
	}


#6   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 21 June 2012 - 06:23 PM

Ok.... So when I revert back to the old code all prizes show as zero.... :wacko:

#7   germ

germ
  • Members
  • 13,921 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 21 June 2012 - 10:24 PM

View PostJSR, on 20 June 2012 - 06:55 PM, said:

Hi multimixer,

Thanks for replying!
I do have a dot in admin where the decimal point must be inserted....
So that's not the problem..

Check and be sure that's true for all the currencies.
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#8   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 21 June 2012 - 11:57 PM

Hi Germ,

I have 3 currencies installed (USD default) and all have a dot inserted as decimal point...
English is the only language and language currency is defined as USD.
I also have use default language of currency set to true in admin configuration...

#9 ONLINE   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,390 posts
  • Real Name:George Zarkadas
  • Gender:Male
  • Location:Greece

Posted 22 June 2012 - 04:08 AM

Can you also post the function currencies() of your file? Just post the complete file

#10   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 22 June 2012 - 09:58 AM

Ok, here goes...
<?php
/*
  $Id: currencies.php,v 1.16 2003/06/05 23:16:46 hpdl Exp $
  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com
  Copyright (c) 2003 osCommerce
  Released under the GNU General Public License
*/
////
// Class to handle currencies
// TABLES: currencies
  class currencies {
	var $currencies;
// class constructor
	function currencies() {
	  $this->currencies = array();
	  $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES);
	  while ($currencies = tep_db_fetch_array($currencies_query)) {
		$this->currencies[$currencies['code']] = array('title' => $currencies['title'],
													   'symbol_left' => $currencies['symbol_left'],
													   'symbol_right' => $currencies['symbol_right'],
													   'decimal_point' => $currencies['decimal_point'],
													   'thousands_point' => $currencies['thousands_point'],
													   'decimal_places' => $currencies['decimal_places'],
													   'value' => $currencies['value']);
	  }
	}
   
	///Begin of addition to currencies.php for deposit(deposit payments) mod
function price() {
		global $order;
		$number = $order->info['total'];
		$currency_value = $order->info['currency_value'];
		$rate = (tep_not_null($currency_value)) ? $currency_value :
$this->currencies[$currency_type]['value'];
		$price =  round (($rate * $number), 2)  ;
		return $price;
	}
//End of addition to currencies.php for deposit (deposit payments) mod
// class methods
	function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') {
	  global $currency;
	  if (empty($currency_type)) $currency_type = $currency;
	  if ($calculate_currency_value == true) {
			  $rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
			  $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
			  $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
			  $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . $format_string[1];
			} else {
			  $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
			  $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
			  $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . $format_string[1];
 
			}								 

	  return $format_string;
	}
	function is_set($code) {
	  if (isset($this->currencies[$code]) && tep_not_null($this->currencies[$code])) {
		return true;
	  } else {
		return false;
	  }
	}
	function get_value($code) {
	  return $this->currencies[$code]['value'];
	}
	function get_decimal_places($code) {
	  return $this->currencies[$code]['decimal_places'];
	}
function display_price($products_price, $products_tax, $quantity = 1) {
return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
}
}
?>


#11   germ

germ
  • Members
  • 13,921 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 25 June 2012 - 10:46 AM

After this line of code:

if (empty($currency_type)) $currency_type = $currency;

ADD this code:

	if ( $this->currencies[$currency_type]['decimal_point'] == '' ) {
	  $this->currencies[$currency_type]['decimal_point'] = '.';
	}

This fix is only a "band-aid". It just covers up a problem somewhere else. Where ? - I haven't a clue....

As long as all your currencies use a period for the 'decimal_point" it should work.

Cross your fingers another error doesn't pop up somewhere else.
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#12   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 26 June 2012 - 02:41 PM

Hi germ,

Thanks for the band aid, but all prices turn up as "0." right now.
I'm completely lost :'(
All currencies have use a period forthe decimal point so I don't even know where to look anymore...

#13   germ

germ
  • Members
  • 13,921 posts
  • Real Name:Jim
  • Gender:Male
  • Location:USA (GMT-6)

Posted 26 June 2012 - 09:19 PM

I'm going to go out on a limb and guess the site's been around a while due to the fact it's ancient osC code and has some "non-standard" code applied (maybe an "addon" installed).

I'm also guessing it used to work fine, then something happened to cause the error you first posted about.

So maybe if you elaborate on how you've wound up where you are now we can backtrack and find the malfunction.

Without a little history I wouldn't know where to start looking either.
If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."
- Me -

"Headers already sent" - The definitive help

"Cannot redeclare ..." - How to find/fix it

SSL Implementation Help

Like this post? "Like" it again over there >

#14   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 27 June 2012 - 11:40 AM

You're absolutely right, germ!! Ok, so I finally figured it out... Please don't be mad at me guys.... >_<
I have an alteration in application_top that gets the customer country from the ip address and changes the currency accordingly.
But I also removed countries that I don't ship to.
So last year I moved to a country that isn't listed in admin.
That's why prices where showing up as 0 (even with the default code); my country ip could not be verified anymore... :blush:
I'm so very sorry about bothering you guys with this issue when it's something that you had no way of knowing in the 1st place...
Please accept my apologies :sweating:

#15 ONLINE   multimixer

multimixer

    Lemons or Melons ?

  • Partner
  • 4,390 posts
  • Real Name:George Zarkadas
  • Gender:Male
  • Location:Greece

Posted 27 June 2012 - 02:16 PM

ok, time for a beer then :)

#16   JSR

JSR
  • Members
  • 149 posts
  • Real Name:Chanel
  • Gender:Female
  • Location:Planet Earth

Posted 02 July 2012 - 02:05 PM

Yeah, definitely! Germ's post led me in the right direction, because I had totally forgotten about the addon.... :unsure:
It's a good thing though, cause now I know how the site looks for people in unlisted countries...
Thanks again guys! ^_^

Edited by JSR, 02 July 2012 - 02:05 PM.