Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Error on categories/specials in backend; any help?


vashichino7

Recommended Posts

Hello guys,

 

When I access my backend and go to Categories then Specials; I get this warning above the products:

 

Warning: Division by zero in /home/savingsh/public_html/admin/specials.php on line 230

 

When I access specials.php on line 230; here is what I get.

 

$contents[] = array('align' => 'center', 'text' => tep_draw_button(IMAGE_EDIT, 'document', tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=edit')) . tep_draw_button(IMAGE_DELETE, 'trash', tep_href_link(FILENAME_SPECIALS, 'page=' . $HTTP_GET_VARS['page'] . '&sID=' . $sInfo->specials_id . '&action=delete')));

$contents[] = array('text' => '<br />' . TEXT_INFO_DATE_ADDED . ' ' . tep_date_short($sInfo->specials_date_added));

$contents[] = array('text' => '' . TEXT_INFO_LAST_MODIFIED . ' ' . tep_date_short($sInfo->specials_last_modified));

$contents[] = array('align' => 'center', 'text' => '<br />' . tep_info_image($sInfo->products_image, $sInfo->products_name, SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT));

$contents[] = array('text' => '<br />' . TEXT_INFO_ORIGINAL_PRICE . ' ' . $currencies->format($sInfo->products_price));

$contents[] = array('text' => '' . TEXT_INFO_NEW_PRICE . ' ' . $currencies->format($sInfo->specials_new_products_price));

(Line 230) $contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%');

$contents[] = array('text' => '<br />' . TEXT_INFO_EXPIRES_DATE . ' <strong>' . tep_date_short($sInfo->expires_date) . '</strong>');

$contents[] = array('text' => '' . TEXT_INFO_STATUS_CHANGE . ' ' . tep_date_short($sInfo->date_status_change));

 

 

What is this error? How can I fix it? Anyone have an idea? Thank you....

Link to comment
Share on other sites

Hey DunWeb; no I read that this is a php file error. I have not edited this page: here is the fix.

'If you’re projecting a script tide up with math you may encounter a typical error that come out when you try to divide a number by zero.

The result of such operation would be a “number” that leads to infinite so, for this reason, php returns a warning. If this warning if print on screen or not it depends by your php.ini configuration that may be set on E_ALL or not.

The problems starts if you cannot edit the php.ini file like on remote servers that are not completely under your control.'

 

I have gone ahead and added an @ sign before the division is taken place;

 

$contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (@($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%');

 

And the error is fixed.

Link to comment
Share on other sites

Sorry Von,

 

I didn't read your original post properly, I thought you were just experiencing visible code.

 

Glad you got it fixed.

 

 

 

Chris

Link to comment
Share on other sites

That is not a fix. Adding the @ turned off the error message. The error is still there, you are just no longer getting a warning about it.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

I see... the warning for a zero is quite normal and gives warnings for some php's. Is it okay to do what I did?

No, it's not. Here is your code:

$contents[] = array('text' => '' . TEXT_INFO_PERCENTAGE . ' ' . number_format(100 - (@($sInfo->specials_new_products_price / $sInfo->products_price) * 100)) . '%');

$sInfo->products_price has a value of 0 (or is completely undefined, which is more likely). That's what you have to start tracking down. What you did was put a piece of black tape over your car's "Check Engine" light, because its being on annoyed you.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...