View Full Version : [fixed] Division By Zero on showthread
LeeS
Sat 18th May '02, 5:00pm
A user just reported this problem to me, and we've not been able to duplicate it since, but it is bothersome.
Warning: Division by zero in /home/virtual/site1/fst/var/www/html/admin/functions.php on line 46
line 46 in our case is:
$totalpages = ceil($results/$perpage);
from 'getpagenav'
What's this all about? :confused:
eva2000
Sat 18th May '02, 5:15pm
what version of vB and php are you using ?
LeeS
Sat 18th May '02, 6:30pm
4.0.6 (patched) & 2.2.5
Steve Machol
Sat 18th May '02, 6:38pm
What you quoted above is not what's on line 46 of the default functions.php for 2.2.5. This is actually on line 26. You must have modified the file for some hack. Reupload the original file to fix this problem.
LeeS
Sat 18th May '02, 7:46pm
Indeed I have, but it was to add my own function (just my simple ad rotator) and putting it in admin/functions.php was the easiest place to put it within reach of all forum pages. It's a completely isolated function and has no interaction with the section of code in question.
eva2000
Sat 18th May '02, 11:52pm
Originally posted by LeeS
Indeed I have, but it was to add my own function (just my simple ad rotator) and putting it in admin/functions.php was the easiest place to put it within reach of all forum pages. It's a completely isolated function and has no interaction with the section of code in question. does removing your addition fix the problem ?
Scott MacVicar
Sun 19th May '02, 7:46am
If they add &perpage=0 to the url you will get that error, shouldn't there be some error checking to make sure people don't enter that?
Moving to bugs forum.
LeeS
Sun 19th May '02, 7:54am
Like I said it was a freak incident, we've not been able to replicate it, including the person who first got the error. It's possible (as said above) someone dropped in a malformed url as a link within a message.
Was just a curious incident that may or may not, have deeper roots. Thought it was worth reporting. :)
Scott MacVicar
Sun 19th May '02, 8:04am
Adding &perpage=-1 has intresting results as well. I'd have to say its most likely that they were given a malformed URL with a perpage=0 within it, and there is error checking to make sure they can't set their maxposts in options to 0 or -1 but no check if they passed it in the url.
Mike Sullivan
Sun 19th May '02, 11:36pm
Simple fix.
if (!isset($perpage)) {
to:
$perpage = intval($perpage);
if ($perpage < 1) {
in showthread.php
Powered by vBulletin™ Version 4.0.0 Beta 4 Copyright © 2009 vBulletin Solutions, Inc. All rights