Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2010
    Posts
    64
    Plugin Contributions
    0

    Default PHP Warning: Division by zero header_php_review.php

    I am getting this error in the logs?

    PHP Warning: Division by zero in /var/www/vhosts/website.com/httpdocs/includes/modules/pages/product_info/header_php_review.php on line 87


    PHP Code:
      /* Average rating Calculation */
      
    $sizeOfAverage count($reviewsAverageArray);
      for(
    $i=0$i $sizeOfAverage$i++) { 
        
    $averageRating += $reviewsAverageArray[$i];
      }
      
    $averageRating round($averageRating/$sizeOfAverage); 

  2. #2
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: PHP Warning: Division by zero header_php_review.php

    Suggest visiting the forum related to the plugin. There ought to be a check for the non-existence of reviews and an appropriate assignment if none have been provided. Perhaps if the average is 0 it knows that none have been provided and if so, then would modify to:
    Code:
    if ($sizeOfAverage>0) {
    $averageRating = round($averageRating/$sizeOfAverage);
    } else {
    $averageRating = 0;
    }
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,703
    Plugin Contributions
    123

    Default Re: PHP Warning: Division by zero header_php_review.php

    I would not compute an average if no data exists. The value only makes sense if $sizeOfAverage > 0.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  4. #4
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: PHP Warning: Division by zero header_php_review.php

    Quote Originally Posted by swguy View Post
    I would not compute an average if no data exists. The value only makes sense if $sizeOfAverage > 0.
    Generally would agree, also wouldn't program to have the possibility of a divide by zero... Thing is that without knowing how it deals with the condition otherwise, I chose to assgn it a value as it doesn't make sense inmost rating systems for the value of zero to be chosen by a customer... Typically would expect 1 to be theminmum and that a check for display would be if average is equal to or greater than 1 then show rating otherwise request first rating... But maybe that's just me...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  5. #5
    Join Date
    Sep 2010
    Posts
    64
    Plugin Contributions
    0

    Default Re: PHP Warning: Division by zero header_php_review.php

    That Solved the Problem. I really appreciate the help. The Error was creating a ton of log files and now there are none.

  6. #6
    Join Date
    Jul 2012
    Posts
    16,734
    Plugin Contributions
    17

    Default Re: PHP Warning: Division by zero header_php_review.php

    Quote Originally Posted by cyberfolli View Post
    That Solved the Problem. I really appreciate the help. The Error was creating a ton of log files and now there are none.
    Please verify though that you don't have bad ratings on items that actually don't have a review yet provided. (This was the next step/test in case the code handled a zero differently than a non-assignment) and is one aspect to which I believe swguy was suggesting could appear as a problem.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v151 PHP Warning: Division by zero in public_html/store/includes/classes/c
    By lilly06 in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 2
    Last Post: 27 Sep 2013, 06:29 PM
  2. Replies: 11
    Last Post: 1 Feb 2013, 07:12 PM
  3. Warning: Division by zero in attributes_controller.php
    By Snicklefritz in forum Setting Up Categories, Products, Attributes
    Replies: 14
    Last Post: 12 May 2010, 04:19 PM
  4. Warning: Division by zero in /includes/classes/shipping.php on line 94
    By keycraze in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 21 Sep 2008, 09:40 PM
  5. Replies: 3
    Last Post: 27 Jan 2007, 05:31 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR