From 984a2aaf773c549369ff3ecf0c61c67625a7edb1 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 29 Apr 2006 21:12:05 +0000 Subject: [PATCH] r771: Remove divide by zero warnings --- showreport.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/showreport.php b/showreport.php index 836354c..bd03424 100644 --- a/showreport.php +++ b/showreport.php @@ -277,8 +277,16 @@ if ($show['getattachments'] OR $show['putattachments']) $vote = $db->query_first("SELECT *, FIND_IN_SET(" . $bugsys->userinfo['userid'] . ", userids) AS uservote FROM " . TABLE_PREFIX . "vote WHERE bugid = $bug[bugid]"); $vote['total'] = $vote['votefor'] + $vote['voteagainst']; -$vote['forpercent'] = round($vote['votefor'] / $vote['total'], 3) * 100; -$vote['againstpercent'] = round($vote['voteagainst'] / $vote['total'], 3) * 100; +if ($vote['total'] != 0) +{ + $vote['forpercent'] = round($vote['votefor'] / $vote['total'], 3) * 100; + $vote['againstpercent'] = round($vote['voteagainst'] / $vote['total'], 3) * 100; +} +else +{ + $vote['forpercent'] = 0; + $vote['againstpercent'] = 0; +} $show['vote'] = ((can_perform('canvote', $bug['productid']) AND !$vote['uservote']) ? true : false); -- 2.22.5