If this is your first visit, check our documentation. To post, register or login.
Forums / Bug Reports / [Done 1.3.6] Reg_Empty error in additional image

[Done 1.3.6] Reg_Empty error in additional image

Locked

Started by anita on 16 Sep 2006, 12:56 AM · Views: 4,699

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
16 Sep 2006, 12:56 AM
#1
anita avatar

anita

Zen Follower

Join Date:
Feb 2006
Posts:
124
Plugin Contributions:
0

[Done 1.3.6] Reg_Empty error in additional image

I am occassionally getting the following error message in my error log:

PHP Warning: ereg_replace(): REG_EMPTY in /xxxxx/xxxxx/xxxxx/includes/modules/pages/popup_image_additional/header_php.php on line 35

and I think that this is line 35
$products_image_base = ereg_replace($products_image_extention, '', $products_image);

Anyone have an idea what would case this?

18 Sep 2006, 8:36 PM
#2
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: [Done 1.3.6] Reg_Empty error in additional image

I too have noticed the below error when using additional images with version 1.3.5

[17-Sep-2006 19:41:06] PHP Warning:  ereg_replace() [<a href='function.ereg-replace'>function.ereg-replace</a>]: REG_EMPTY in D:\server\store\includes\modules\pages\popup_image_additional\header_php.php on line 33

It appears to be caused by the ereg_replace function having an empty replace string parameter. I have subsequently changed the line that says:

$products_image_base = ereg_replace($products_image_extension, '', $products_image);

to read:

$products_image_base = substr($products_image, 0, strrpos($products_image, '.'));

By using the substr() function rather than the ereg_replace() function the error is elimiated and the effect of the code is the same.

Hope this helps!

Jeff

18 Sep 2006, 8:50 PM
#3
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Re: [Done 1.3.6] Reg_Empty error in additional image

anita:

$products_image_base = ereg_replace($products_image_extention, '', $products_image);
This is old code.

The word "extention" was corrected to "extension" in v1.3.0...

Are you using mismatched code, and thus have an empty value due to a non-defined variable?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Sep 2006, 9:06 PM
#4
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: [Done 1.3.6] Reg_Empty error in additional image

Dr. Byte,

Here is the code I am using, taken directly from the 1.3.5 archive.

<?php
/**
 * pop up image additional
 *
 * @package page
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: header_php.php 2984 2006-02-07 22:00:25Z drbyte $
 */
// This should be first line of the script:
  $zco_notifier->notify('NOTIFY_HEADER_START_POPUP_IMAGES_ADDITIONAL');

  $_SESSION['navigation']->remove_current_page();

  $products_values_query = "SELECT pd.products_name, p.products_image
                            FROM " . TABLE_PRODUCTS . " p
                            left join " . TABLE_PRODUCTS_DESCRIPTION . " pd
                            on p.products_id = pd.products_id
                            WHERE p.products_status = 1
                            and p.products_id = :productsID
                            and pd.language_id = :languagesID ";

  $products_values_query = $db->bindVars($products_values_query, ':productsID', $_GET['pID'], 'integer');
  $products_values_query = $db->bindVars($products_values_query, ':languagesID', $_SESSION['languages_id'], 'integer');

  $products_values = $db->Execute($products_values_query);


  $products_image = $products_values->fields['products_image'];

  $products_image_extension = substr($products_image, strrpos($products_image, '.'));
  $products_image_base = ereg_replace($products_image_extension, '', $products_image);
  $products_image_medium = $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extension;
  $products_image_large = $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extension;

  // This should be last line of the script:
  $zco_notifier->notify('NOTIFY_HEADER_END_POPUP_IMAGES_ADDITIONAL');
?>

The problem is caused by the fact that on line 33 the second argument to ereg_replace() is an empty string which appears to be producing the warning. The simple change I submitted correct the error log write.

Thanks,
Jeff

25 Sep 2006, 1:59 PM
#5
dbrewster avatar

dbrewster

Zen Follower

Join Date:
Jul 2005
Location:
Charlottesville, VA
Posts:
376
Plugin Contributions:
0

Re: [Done 1.3.6] Reg_Empty error in additional image

I saw this same problem in my logs, I'm trying out JeffD's suggested code change, too.

thanks JeffD!!!

---Diana