Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

fatal error cannot redeclare tep_banner_status and other errors with complete review system


Tabitha

Recommended Posts

Posted

Hi, I'm new to html, php, trying to learn empirically, and don't know where to begin on this current issue. I added the complete reviews system contribution (thank you!) so that product reviews could be screened, with the following results:

 

1) lost navbar title for "reviews"

2) when I tested the system initially, it seemed to work - up to the admin email notification that a review had been submitted. But "ADMIN_EMAIL_SUBJECT" was the title, and "ADMIN_EMAIL_MESSAGE" was the sole text - no link or way to approve or reject the review.

 

3) I then added (Admin)V1.5.3, and subsequently got:

 

Fatal error: Cannot redeclare tep_set_banner_status()(previously declared in includes/functions/general.php:698) in includes/functions/banner.php on line 23

 

I undid the modifications re V1.5.3 but I still get the fatal error.

 

Can anyone point me in the right direction (and then help some more when I get stuck again!)? Thanks!

 

Tabitha

Posted

I took a look at this add-on and do not like how it does things.

 

First, note that you have to install two copies: (1) the full package dated 15 Sep 2008, and (2) the admin-only, v. 1.5.3 package dated 3 Aug 2009.

 

Second, for some of the files that already exist in baseline osCommerce, you're replacing them instead of updating them. This could be a problem if they were written for older versions of osCommerce. And I wouldn't be surprised if this was the actual issue behind some of your problems.

 

Now regarding the errors you're seeing:

 

'ADMIN_EMAIL_SUBJECT' and 'ADMIN_EMAIL_MESSAGE' are defined constants. PHP, when a defined constant is referenced but that constant hasn't actually been defined, will use the constant's name as its "value". So what you're seeing is a situation where the code is expecting a constant to be defined but it has not been defined. This typically happens when you have a problem including the file where the constants are defined. The include file containing these particular constants is:

 

catalog/includes/languages/english/product_reviews_write.php

Please post your product_reviews_write.php file here (and be sure to mark it as "code" so that it's more readable).

 

Regarding the error about tep_set_banner_status(), I can think of a few possible causes. First, all of the "admin-only" changes (from the installation instructions) must be made to files in the 'catalog/admin' directory. Did you perhaps make the changes instead to files in the 'catalog' directory that have the same names and directory paths? Also, the admin-only instructions say to modify "includes/languages/english.php", but I believe it's supposed to be "admin/includes/languages/english.php". Third, since the admin-only instructions had you change general.php, and because one of the errors is related to that, perhaps those changes are what caused something to break.

 

This should be enough to point you in the right direction. Here's your chance to learn PHP the hard way!

Check out Chad's News.

Posted

I took a look at this add-on and do not like how it does things.

 

First, note that you have to install two copies: (1) the full package dated 15 Sep 2008, and (2) the admin-only, v. 1.5.3 package dated 3 Aug 2009.

 

Second, for some of the files that already exist in baseline osCommerce, you're replacing them instead of updating them. This could be a problem if they were written for older versions of osCommerce. And I wouldn't be surprised if this was the actual issue behind some of your problems.

 

Now regarding the errors you're seeing:

 

'ADMIN_EMAIL_SUBJECT' and 'ADMIN_EMAIL_MESSAGE' are defined constants. PHP, when a defined constant is referenced but that constant hasn't actually been defined, will use the constant's name as its "value". So what you're seeing is a situation where the code is expecting a constant to be defined but it has not been defined. This typically happens when you have a problem including the file where the constants are defined. The include file containing these particular constants is:

 

catalog/includes/languages/english/product_reviews_write.php

Please post your product_reviews_write.php file here (and be sure to mark it as "code" so that it's more readable).

 

Regarding the error about tep_set_banner_status(), I can think of a few possible causes. First, all of the "admin-only" changes (from the installation instructions) must be made to files in the 'catalog/admin' directory. Did you perhaps make the changes instead to files in the 'catalog' directory that have the same names and directory paths? Also, the admin-only instructions say to modify "includes/languages/english.php", but I believe it's supposed to be "admin/includes/languages/english.php". Third, since the admin-only instructions had you change general.php, and because one of the errors is related to that, perhaps those changes are what caused something to break.

 

This should be enough to point you in the right direction. Here's your chance to learn PHP the hard way!

Posted

Hi, Thanks for the helpful and clear explanation.

 

One clarification re addon - I used the complete_reviews_system_with_star_rating as the full package.

 

Re Tep_set_banner_status(): the "admin-only" modifications were made in the catalog/admin directory except for the instructions for includes/languages/english.php. Because the instructions didn't specify, I had made that change to catalog/includes/languages/english.php. I think I've reversed all of the admin-only instructions but the error remains, even though the general,php file should be the original.

 

 

Here is the code for the catalog/includes/languages/english/product_reviews_write.php file:

<?php
/*
 $Id: product_reviews_write.php,v 1.55 2003/06/20 14:25:58 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

 require('includes/application_top.php');

 if (!tep_session_is_registered('customer_id')) {
   $navigation->set_snapshot();
   tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));
 }

 $product_info_query = tep_db_query("select p.products_id, p.products_model, p.products_image, p.products_price, p.products_tax_class_id, pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "'");
 if (!tep_db_num_rows($product_info_query)) {
//*** <Reviews Mod>
   tep_redirect(tep_href_link(FILENAME_REVIEW_NOTICE, tep_get_all_get_params(array('action'))));
//*** </Reviews Mod>
 } else {
   $product_info = tep_db_fetch_array($product_info_query);
 }

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

 if (isset($HTTP_GET_VARS['action']) && ($HTTP_GET_VARS['action'] == 'process')) {
   $rating = tep_db_prepare_input($HTTP_POST_VARS['rating']);
   $review = tep_db_prepare_input($HTTP_POST_VARS['review']);

   $error = false;
   if (strlen($review) < REVIEW_TEXT_MIN_LENGTH) {
     $error = true;

     $messageStack->add('review', JS_REVIEW_TEXT);
   }

//*** <Reviews Mod>
   if (($rating < 1) || ($rating > 5)) {
     $error = true;

     $messageStack->add('review', JS_REVIEW_RATING);
   }
//*** </Reviews Mod>

   if ($error == false) {
     tep_db_query("insert into " . TABLE_REVIEWS . " (products_id, customers_id, customers_name, reviews_rating, date_added) values ('" . (int)$HTTP_GET_VARS['products_id'] . "', '" . (int)$customer_id . "', '" . tep_db_input($customer['customers_firstname']) . ' ' . tep_db_input($customer['customers_lastname']) . "', '" . tep_db_input($rating) . "', now())");
     $insert_id = tep_db_insert_id();

     tep_db_query("insert into " . TABLE_REVIEWS_DESCRIPTION . " (reviews_id, languages_id, reviews_text) values ('" . (int)$insert_id . "', '" . (int)$languages_id . "', '" . tep_db_input($review) . "')");

//*** <Reviews Mod>
     tep_mail(STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS, ADMIN_EMAIL_SUBJECT, ADMIN_EMAIL_MESSAGE, ADMIN_EMAIL_FROM_NAME, STORE_OWNER_EMAIL_ADDRESS);
     tep_redirect(tep_href_link(FILENAME_REVIEW_NOTICE, tep_get_all_get_params(array('action'))));
//*** </Reviews Mod>
   }
 }

 if ($new_price = tep_get_products_special_price($product_info['products_id'])) {
   $products_price = '<s>' . $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($product_info['products_tax_class_id'])) . '</span>';
 } else {
   $products_price = $currencies->display_price($product_info['products_price'], tep_get_tax_rate($product_info['products_tax_class_id']));
 }

 if (tep_not_null($product_info['products_model'])) {
   $products_name = $product_info['products_name'] . '<br><span class="smallText">[' . $product_info['products_model'] . ']</span>';
 } else {
   $products_name = $product_info['products_name'];
 }

 require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_PRODUCT_REVIEWS_WRITE);

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params()));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
<script language="javascript"><!--
function checkForm() {
 var error = 0;
 var error_message = "<?php echo JS_ERROR; ?>";

 var review = document.product_reviews_write.review.value;

 if (review.length < <?php echo REVIEW_TEXT_MIN_LENGTH; ?>) {
   error_message = error_message + "<?php echo JS_REVIEW_TEXT; ?>";
   error = 1;
 }

 if ((document.product_reviews_write.rating[0].checked) || (document.product_reviews_write.rating[1].checked) || (document.product_reviews_write.rating[2].checked) || (document.product_reviews_write.rating[3].checked) || (document.product_reviews_write.rating[4].checked)) {
 } else {
   error_message = error_message + "<?php echo JS_REVIEW_RATING; ?>";
   error = 1;
 }

 if (error == 1) {
   alert(error_message);
   return false;
 } else {
   return true;
 }
}

function popupWindow(url) {
 window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}
//--></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->

<!-- body //-->
<table border="0" width="100%" cellspacing="3" cellpadding="3">
 <tr>
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- left_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
<!-- left_navigation_eof //-->
   </table></td>
<!-- body_text //-->
   <td width="100%" valign="top"><?php echo tep_draw_form('product_reviews_write', tep_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, 'action=process&products_id=' . $HTTP_GET_VARS['products_id']), 'post', 'onSubmit="return checkForm();"'); ?><table border="0" width="100%" cellspacing="0" cellpadding="0">
     <tr>
       <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
         <tr>
           <td class="pageHeading" valign="top"><?php echo $products_name; ?></td>
           <td class="pageHeading" align="right" valign="top"><?php echo $products_price; ?></td>
         </tr>
       </table></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 if ($messageStack->size('review') > 0) {
?>
     <tr>
       <td><?php echo $messageStack->output('review'); ?></td>
     </tr>
     <tr>
       <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
     </tr>
<?php
 }
?>
     <tr>
       <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
         <tr>
           <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php //*** <Reviews Mod> ?>
             <tr>
               <td class="main"><?php echo SUB_TITLE_EXPLAIN; ?></td>
             </tr>
<?php //*** </Reviews Mod> ?>
             <tr>
               <td class="main"><?php echo '<b>' . SUB_TITLE_FROM . '</b> ' . tep_output_string_protected($customer['customers_firstname'] . ' ' . $customer['customers_lastname']); ?></td>
             </tr>
             <tr>
               <td class="main"><b><?php echo SUB_TITLE_REVIEW; ?></b></td>
             </tr>
             <tr>
               <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
                 <tr class="infoBoxContents">
                   <td><table border="0" width="100%" cellspacing="2" cellpadding="2">
                     <tr>
                       <td class="main"><?php echo tep_draw_textarea_field('review', 'soft', 60, 15); ?></td>
                     </tr>
                     <tr>
<?php //*** <Reviews Mod> ?>
                       <td class="smallText" align="right"><?php //echo TEXT_NO_HTML; ?></td>
<?php //*** </Reviews Mod> ?>
                     </tr>
                     <tr>
<?php //*** <Reviews Mod> ?>
                       <td class="main"><?php echo '<b>' . SUB_TITLE_RATING . '</b> ' . TEXT_BAD . ' ' . tep_draw_radio_field('rating', '1') . ' ' . tep_draw_radio_field('rating', '2') . ' ' . tep_draw_radio_field('rating', '3') . ' ' . tep_draw_radio_field('rating', '4') . ' ' . tep_draw_radio_field('rating', '5') . ' ' . TEXT_GOOD; ?></td>
<?php //*** </Reviews Mod> ?>
                     </tr>
                   </table></td>
                 </tr>
               </table></td>
             </tr>
             <tr>
               <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
             </tr>
             <tr>
               <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox">
                 <tr class="infoBoxContents">
                   <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
                     <tr>
                       <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                       <td class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_REVIEWS, tep_get_all_get_params(array('reviews_id', 'action'))) . '">' . tep_image_button('button_back.gif', IMAGE_BUTTON_BACK) . '</a>'; ?></td>
                       <td class="main" align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td>
                       <td width="10"><?php echo tep_draw_separator('pixel_trans.gif', '10', '1'); ?></td>
                     </tr>
                   </table></td>
                 </tr>
               </table></td>
             </tr>
           </table></td>
           <td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" align="right" valign="top"><table border="0" cellspacing="0" cellpadding="2">
             <tr>
               <td align="center" class="smallText">
<?php
 if (tep_not_null($product_info['products_image'])) {
?>
<script language="javascript"><!--
document.write('<?php echo '<a href="javascript:popupWindow(\\\'' . tep_href_link(FILENAME_POPUP_IMAGE, 'pID=' . $product_info['products_id']) . '\\\')">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], addslashes($product_info['products_name']), SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>');
//--></script>
<noscript>
<?php echo '<a href="' . tep_href_link(DIR_WS_IMAGES . $product_info['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $product_info['products_image'], $product_info['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5"') . '<br>' . TEXT_CLICK_TO_ENLARGE . '</a>'; ?>
</noscript>
<?php
 }

 echo '<p><a href="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now') . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a></p>';
?>
               </td>
             </tr>
           </table>
         </td>
       </table></td>
     </tr>
   </table></form></td>
<!-- body_text_eof //-->
   <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="0" cellpadding="2">
<!-- right_navigation //-->
<?php require(DIR_WS_INCLUDES . 'column_right.php'); ?>
<!-- right_navigation_eof //-->
   </table></td>
 </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

 

Thanks again,

Tabitha.

Posted

PLEASE DISREGARD CODE POSTED IN PREVIOUS POST. THIS POST HAS THE CODE OF THE CORRECT FILE:catalog/includes/languages/english/product_reviews_write.

 

Hi, Thanks for the helpful and clear explanation.

 

One clarification re addon - I used the complete_reviews_system_with_star_rating as the full package.

 

Re Tep_set_banner_status(): the "admin-only" modifications were made in the catalog/admin directory except for the instructions for includes/languages/english.php. Because the instructions didn't specify, I had made that change to catalog/includes/languages/english.php. I think I've reversed all of the admin-only instructions but the error remains, even though the general,php file should be the original.

 

 

Here is the code for the catalog/includes/languages/english/product_reviews_write.php file:

 

<?php
/*
 $Id: product_reviews_write.php,v 1.0 2006/07/18 23:23:52 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com

 Copyright (c) 2006 osCommerce

 Released under the GNU General Public License
*/

define('NAVBAR_TITLE', 'Reviews');

define('SUB_TITLE_FROM', 'From:');
define('SUB_TITLE_REVIEW', 'Your Review:');
//*** <Reviews Mod>
define('ADMIN_EMAIL_SUBJECT', 'Product Review - Approval Required');
define('ADMIN_EMAIL_MESSAGE', 'There is a new product review awaiting approval from your online store, please click this link to view this review: <a href="' . tep_href_link(FILENAME_PRODUCT_REVIEW_EMAIL) . '">' . tep_href_link(FILENAME_PRODUCT_REVIEW_EMAIL) . '</a>');
define('ADMIN_EMAIL_FROM_NAME', 'Product Reviews');
define('SUB_TITLE_EXPLAIN', '
<hr />
<h2>Review Guidelines</h2>
<h3>We want your comments!</h3>
<p>We’re interested in your opinion of this product. Let us and other customers know how you feel by filling in the comment field below. We reserve the right to accept, reject, or edit product reviews; therefore, your review may not appear immediately.</p>
<ul>
<li>Please <strong>do:</strong>
<ul>
<li>write 50-300 words for the product</li>
<li>comment on the product’s value and effectiveness</li>
<li>tell us if you like the product, but most importantly explain <strong>why</strong> you like or dislike it</li>
<li>mention related products and how this one rates by comparison</li>
</ul>
</li>
<li>Please <strong>do not:</strong>
<ul>
<li>use profanity, obscenities, or make spiteful remarks</li>
<li>type phone numbers, mail addresses, or URLs</li>
<li>make note of availability, price, or alternative ordering/shipping information</li>
</ul>
</li>
</ul>
<hr />
');
//*** </Reviews Mod>
define('SUB_TITLE_RATING', 'Rating:');

define('TEXT_NO_HTML', '<small><font color="#ff0000"><b>NOTE:</b></font></small> HTML is not translated!');
define('TEXT_BAD', '<small><font color="#ff0000"><b>BAD</b></font></small>');
define('TEXT_GOOD', '<small><font color="#ff0000"><b>GOOD</b></font></small>');

define('TEXT_CLICK_TO_ENLARGE', 'Click to enlarge');
?>

 

Thanks again,

Tabitha.

Posted

Okay, I don't see a problem with that file. So it may be that you're not including it somewhere.

Check out Chad's News.

Posted

Hi, I uninstalled and reinstalled the php files - and the same error still exists. I then replaced the modified php files with the originals. I don't know what to do with the reviews.sql file that was uploaded - have now realized that the install instructions said to backup <database> <backup>reviews reviews_description</backup>, and I didn't back up either the review or reviews_description sql files. I am assuming I need to replace the reviews.sql file with the original but I don't know where to find it! Never dealt with any of this before, but trying to learn.

 

Tabitha.

Posted

Check your /admin/includes/application_top.php

 

There shouldn't be any reference to anything about "banner" there.

 

Also check /catalog/includes/functions/general.php

 

There shouldn't be any reference to anything about "banner" there either.

 

If you've accidenatlly uploaded a "catalog" file into the "admin" (or vice versa) you can have problems like this.

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 >

Posted

Hi - thanks,

 

admin/includes/application_top.php: no mention of "banner"

 

catalog/includes/functions/general.php has the following code:

// Sets the status of a banner
 function tep_set_banner_status($banners_id, $status) {
   if ($status == '1') {
     return tep_db_query("update " . TABLE_BANNERS . " set status = '1', expires_impressions = NULL, expires_date = NULL, date_status_change = NULL where banners_id = '" . $banners_id . "'");
   } elseif ($status == '0') {
     return tep_db_query("update " . TABLE_BANNERS . " set status = '0', date_status_change = now() where banners_id = '" . $banners_id . "'");
   } else {
     return -1;
   }
 }

 

(AND ALSO code re "function tep_banner_image extension").

 

I tried deleting the above code - still get same "fatal error: Cannot redeclare tep_set_banner_status()(previously declared in includes/functions/general.php:698) in includes/functions/banner.php on line 23".

 

I have tried reinstalling php files several times trying to keep track of "catalog" and "admin" files - will try one more time. Can someone confirm, as per Chad's suggestion, if the admin-only instructions for english.php refer to ADMIN/includes/languages/english.php rather than the CATALOG/includes/languages/english.php? The instructions word it "includes/languages/english.php

 

Any other suggestions?

 

Thanks again,

Tabitha.

Posted

Hi, you guys were right - after uninstalling and installing individual files several times, I found that the following errors were due to a mixup in catalog and admin files (general.php) from prior modifications.

 

"cannot redeclare tep_set_banner_status() (previously declared in catalog/ includes/functions/general.php:698) in admin /includes/functions/banner.php "

"cannot redeclare tep_set_specials_status() (previously declared in catalog/includes/functions/general.php) in /catalog/includes/functions/specials.php on line 17.

Call to undefined function tep_has_category_subcategories() in store/includes/boxes/categories.php on line 41.

 

THANKS!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...