poe Posted March 21, 2007 Share Posted March 21, 2007 i get this error message: Warning: Division by zero in pro-showBBL.class.php on line .... how do i avoid this error? function calcL5ttlBBL($idTeam, $thePitcher, $what) { $ttl_w = 0; $ttl_l = 0; $pitchL5 = getPitchL5($thePitcher); for($x=0; $x<count($pitchL5); $x++) { if($pitchL5[$x]['wlt'] == "w") { $ttl_w = $ttl_w + 1; } if($pitchL5[$x]['wlt'] == "l") { $ttl_l = $ttl_l + 1; } if($pitchL5[$x]['ip'] ==0) { $ttl_ip = $ttl_ip + 0; } else { $ttl_ip = $ttl_ip + $pitchL5[$x]['ip']; } if($pitchL5[$x]['er'] ==0) { $ttl_er = $ttl_er + 0; } else { $ttl_er = $ttl_er + $pitchL5[$x]['er']; } if($pitchL5[$x]['h'] ==0) { $ttl_h = $ttl_h + 0; } else { $ttl_h = $ttl_h + $pitchL5[$x]['h']; } if($pitchL5[$x]['bb'] ==0) { $ttl_bb = $ttl_bb + 0; } else { $ttl_bb = $ttl_bb + $pitchL5[$x]['bb']; } if($pitchL5[$x]['hr'] ==0) { $ttl_hr = $ttl_hr + 0; } else { $ttl_hr = $ttl_hr + $pitchL5[$x]['hr']; } if($pitchL5[$x]['so'] ==0) { $ttl_so = $ttl_so + 0; } else { $ttl_so = $ttl_so + $pitchL5[$x]['so']; } } $tblRow = "<tr>\n"; $tblRow .= "<td align=right class=l5ttl>" . "TTL:</td>\n"; // game $tblRow .= "<td align=center class=l5ttl> </td>\n"; $tblRow .= "<td align=center class=l5ttl>" . $ttl_w . "-" . $ttl_l . "</td>\n"; ***ERROR ROW*** $tblRow .= "<td align=center class=l5ttl>" . sprintf( "%01.2f", (($ttl_er * 9)/$ttl_ip)) . "</td>\n"; $tblRow .= "<td align=center class=l5ttl>" . $ttl_ip . "</td>\n"; $tblRow .= "<td align=center class=l5ttl>" . $ttl_er . "</td>\n"; $tblRow .= "<td align=center class=l5ttl>" . $ttl_h . "</td>\n"; $tblRow .= "<td align=center class=l5ttl>" . $ttl_bb . "</td>\n"; ***ERROR ROW*** $tblRow .= "<td align=center class=l5ttl>" . sprintf( "%01.2f", (($ttl_bb + $ttl_h)/$ttl_ip)) . "</td>\n"; $tblRow .= "<td align=center class=l5ttl>" . $ttl_hr . "</td>\n"; $tblRow .= "<td align=center class=l5ttl>" . $ttl_so . "</td>\n"; $tblRow .= "<td align=center class=l5ttl>" . "</td>\n"; $tblRow .= "<td align=center class=l5ttl>" . "</td>\n"; $tblRow .= "<td align=center class=l5ttl>" . "</td>\n"; $tblRow .= "</tr>\n"; } // end function Link to comment https://forums.phpfreaks.com/topic/43621-warning-division-by-zero/ Share on other sites More sharing options...
DanDaBeginner Posted March 21, 2007 Share Posted March 21, 2007 I guess your divisor were 0 thats why your getting this error.. ex 50/0 Link to comment https://forums.phpfreaks.com/topic/43621-warning-division-by-zero/#findComment-211832 Share on other sites More sharing options...
per1os Posted March 21, 2007 Share Posted March 21, 2007 Basic math, you cannot divide by zero so avoid it. Link to comment https://forums.phpfreaks.com/topic/43621-warning-division-by-zero/#findComment-211944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.