Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

modified products_new to free_downloads


14steve14

Recommended Posts

Posted

With the help of another firum i have modified the products_new file to work as a free downloads file., but i am getting an error on the page. Can someone see why i am getting this error please

 

Warning: Division by zero in /home/railway1/public_html/includes/classes/split_page_results.php on line 59

 

Here is the page code

<?php
/*
 $Id: free_downloads.php 1739 2007-12-20 00:52:16Z hpdl $

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

 Copyright (c) 2003 osCommerce

 Released under the GNU General Public License
*/

// added for New Product Icon contribution
 $today_time = time();
// end addition
 require('includes/application_top.php');

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

 $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_FREE_DOWNLOADS));
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<?php
/*** Begin Header Tags SEO ***/
if ( file_exists(DIR_WS_INCLUDES . 'header_tags.php') ) {
 require(DIR_WS_INCLUDES . 'header_tags.php');
} else {
?>
 <title><?php echo TITLE; ?></title>
<?php
}
/*** End Header Tags SEO ***/
?>
<base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
<link rel="stylesheet" type="text/css" href="stylesheet.css">
</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"><table border="0" width="100%" cellspacing="0" cellpadding="0">
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="0">
	  <tr>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 $free_downloads_array = array();

 $free_downloads_query_raw = "select p.products_id, pd.products_name, p.products_image, p.products_price, p.products_tax_class_id, p.products_date_added, m.manufacturers_name from " . TABLE_PRODUCTS . " p left join " . TABLE_MANUFACTURERS . " m on (p.manufacturers_id = m.manufacturers_id), " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and products_price = '0' and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and p.products_date_added > date_sub(now(), interval 1 month) order by p.products_date_added DESC, pd.products_name";
 $free_downloads_split = new splitPageResults($free_downloads_query_raw, MAX_DISPLAY_FREE_DOWNLOADS);

 if (($free_downloads_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="smallText"><?php echo $free_downloads_split->display_count(TEXT_DISPLAY_NUMBER_OF_free_downloads); ?></td>
		<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $free_downloads_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
	  </tr>
	</table></td>
  </tr>
  <tr>
	<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
  </tr>
<?php
 }
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
 if ($free_downloads_split->number_of_rows > 0) {
$free_downloads_query = tep_db_query($free_downloads_split->sql_query);
while ($free_downloads = tep_db_fetch_array($free_downloads_query)) {
  if ($new_price = tep_get_products_special_price($free_downloads['products_id'])) {
	$products_price = '<s>' . $currencies->display_price($free_downloads['products_price'], tep_get_tax_rate($free_downloads['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($free_downloads['products_tax_class_id'])) . '</span>';
  } else {
	$products_price = $currencies->display_price($free_downloads['products_price'], tep_get_tax_rate($free_downloads['products_tax_class_id']));
  }
$sql = 'SELECT `products_description` FROM `products_description` WHERE products_id ='.$free_downloads['products_id'].' && language_id='.(int)$languages_id;
$description_query = tep_db_query($sql);
$description = mysql_fetch_array($description_query, MYSQL_ASSOC);		
$description['products_description'] = substr($description['products_description'], 0, 100);
$desc_len = strlen($description['products_description']);
$description['products_description'][$desc_len-1] = '.';
$description['products_description'][$desc_len-2] = '.';
$description['products_description'][$desc_len-3] = '.';
// added for New Product Icon contribution
 // convert times to unix timestamp for comparison
 //  2592000 = 30 days in the unix timestamp format
   if ( ($today_time - strtotime($free_downloads['products_date_added']) ) < 2592000)	  {
	   $free_downloads['products_name'] .= ' ' .'<br>'. tep_image_button('icon_newarrival.gif', TEXT_ICON_NEW_PRODUCT);
   } 
 // end addition New Product Icon contribution
?>
	  <tr>
		<td width="<?php echo SMALL_IMAGE_WIDTH + 10; ?>" rowspan="2" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $free_downloads['products_id']) . '">' . tep_image(DIR_WS_IMAGES . $free_downloads['products_image'], $free_downloads['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT) . '</a>'; ?></td>
		<td rowspan="2" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $free_downloads['products_id']) . '"><b><u>' . $free_downloads['products_name'] . '</u></b></a><br>' . strip_tags($description['products_description']) . '<a href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $free_downloads['products_id']). '">' . DESCR_READ_MORE . '</a><br> '; ?></td>
		<td align="right" valign="top" class="main"><b><?php echo TEXT_PRICE . ' ' . $products_price; ?></b></td>
	  </tr>
	  <tr>
		<td align="right" valign="top" class="main"><?php echo '<a href="' . tep_href_link(FILENAME_free_downloads, tep_get_all_get_params(array('action')) . 'action=buy_now&products_id=' . $free_downloads['products_id']) . '">' . tep_image_button('button_in_cart.gif', IMAGE_BUTTON_IN_CART) . '</a>'; ?></td>
	  </tr>
	  <tr>
		<td colspüan="3" align="right"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
	  </tr>
<?php
}
 } else {
?>
	  <tr>
		<td class="main"><?php echo TEXT_NO_NEW_PRODUCTS; ?></td>
	  </tr>
	  <tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
	  </tr>
<?php
 }
?>
	</table></td>
  </tr>
<?php
 if (($free_downloads_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {
?>
  <tr>
	<td><table border="0" width="100%" cellspacing="0" cellpadding="2">
	  <tr>
		<td class="smallText"><?php echo $free_downloads_split->display_count(TEXT_DISPLAY_NUMBER_OF_free_downloads); ?></td>
		<td align="right" class="smallText"><?php echo TEXT_RESULT_PAGE . ' ' . $free_downloads_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
	  </tr>
	</table></td>
  </tr>
<?php
 }
?>
</table></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'); ?>

 

Its probably something silly, but i cant see it.

REMEMBER BACKUP, BACKUP AND BACKUP

Archived

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

×
×
  • Create New...