Title: [Plugin: WP-Polls] Math calculation error &#8211; PHP warning!
Last modified: August 20, 2016

---

# [Plugin: WP-Polls] Math calculation error – PHP warning!

 *  [biswajeet](https://wordpress.org/support/users/biswajeet/)
 * (@biswajeet)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-polls-math-calculation-error-php-warning/)
 *     ```
       PHP Warning:  Division by zero in /***/plugins/wp-polls/wp-polls.php on line 605
       ```
   
 * I think this error result from when having some total no. of votes but a particular
   choice answer have 0 vote and while calculating % for it. It shows as 1% rather
   than 0%
 * need rectification,
    thanks.
 * [http://wordpress.org/extend/plugins/wp-polls/](http://wordpress.org/extend/plugins/wp-polls/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Thread Starter [biswajeet](https://wordpress.org/support/users/biswajeet/)
 * (@biswajeet)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-wp-polls-math-calculation-error-php-warning/#post-2861913)
 * Ok I think I have found the error:
    The error was in the following code –
 *     ```
       // Make Sure That Total Percentage Is 100% By Adding A Buffer To The Last Poll Answer
       if($poll_multiple_ans == 0) {
        $poll_answer_percentage_array[] = $poll_answer_percentage;
        if(sizeof($poll_answer_percentage_array) == sizeof($poll_answers)) {
          $percentage_error_buffer = 100 - array_sum($poll_answer_percentage_array);
          $poll_answer_percentage = $poll_answer_percentage + $percentage_error_buffer;
          if($poll_answer_percentage < 0) {
           $poll_answer_percentage = 0;
          }
        }
       }
       ```
   
 * Actually if you allow user to select more than one answer, then only above code
   should execute and for that to check ($poll_multiple_ans == 1). On changing this
   now works fine but still gives error for multiple vote selection case and the
   error is showing 1% for 0 votes.
 *  [figaro1818](https://wordpress.org/support/users/figaro1818/)
 * (@figaro1818)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-polls-math-calculation-error-php-warning/#post-2862115)
 * Thanks for directing me over to this thread. I tried ($poll_multiple_ans == 1)
   and the only change I see is that instead of the 8 Votes for No being 0% it is
   now 27%. But the Yes votes are still coming out to 103%. Any ideas??? Thank you
   again for any help.
 * [http://iszeekrewardsascam.com/](http://iszeekrewardsascam.com/)
 *  [Marko Heijnen](https://wordpress.org/support/users/markoheijnen/)
 * (@markoheijnen)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-polls-math-calculation-error-php-warning/#post-2862119)
 * The line on that error is wrong. I’m now trying to fix some of the issues on 
   github.
 * I change the line:
    $poll_answer_percentage = round((($poll_answer_votes/$poll_question_totalvoters)*
   100)); to $poll_answer_percentage = round((($poll_answer_votes/$poll_question_totalvotes)*
   100));
 *  Thread Starter [biswajeet](https://wordpress.org/support/users/biswajeet/)
 * (@biswajeet)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-wp-polls-math-calculation-error-php-warning/#post-2862121)
 * **Thanks [@marko](https://wordpress.org/support/users/marko/) Heijnen**
 *  [kredit-otziv](https://wordpress.org/support/users/kredit-otziv/)
 * (@kredit-otziv)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-polls-math-calculation-error-php-warning/#post-2862210)
 * thank you Marko Heijnen this really helped.
    but I think the error is not reported
   the total number of voters

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘[Plugin: WP-Polls] Math calculation error – PHP warning!’ is closed to
new replies.

 * ![](https://ps.w.org/wp-polls/assets/icon.svg?rev=977996)
 * [WP-Polls](https://wordpress.org/plugins/wp-polls/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-polls/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-polls/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-polls/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-polls/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-polls/reviews/)

 * 5 replies
 * 4 participants
 * Last reply from: [kredit-otziv](https://wordpress.org/support/users/kredit-otziv/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-polls-math-calculation-error-php-warning/#post-2862210)
 * Status: not resolved