View Full Version : CGI question- Illegal division by zero?
Peachalicious
01-25-2003, 07:15 AM
Hi, I really dont know anything about cgi so I hope someone can clarify this for me :)
Ive been running a guestbook on my website for at least a year now and I checked in on it recently and its not working anymore. When you click the link you just get a blank page. So I checked my error log and this is what it says:
Illegal division by zero at /home/beautif/public_html/cgi-bin/guestbook.cgi line 115.
I have no clue what that means but I assume somethings going on with lin 115. So this is what line 115 is:
$currentpage = ($FORM{'start'} + $entriesperpage + 1) / ($entriesperpage + 1);
Can anyone help? I would really appreciate it!
Philip M
01-27-2003, 06:39 PM
It is hard to comment, but it would appear that there is a defect in the script which has somehow allowed the variable
$entriesperpage
to take the value of -1 (so $entriesperpage +1 = 0)
Division by zero throws an error in any programming language.
You say it worked for a some time before the problem arose. Are you sure you have not changed the script in any way? What happened at the time of failure - for example, did the guestbook reach 100 or some other number of pages?
Which guestbook script are you using?
Peachalicious
01-27-2003, 08:08 PM
Hi! Thanks for your response! To answer your questions, I am using Megabook. I am not sure what happened to cause it to stop working but I thought maybe the same thing you mentioned happened. I hadnt checked in on it for sometime so Im not sure how many entires it had or even when exactly it stoped working. I know it was working for at least 3 months or so. It only had one page of entires the last time I checked it so maybe going to 2 pages is what threw it off?
I hope this is helpful. Thanks for any help you can offer! :)
Philip M
01-29-2003, 07:51 AM
I can only suggest that you start again, that is upload your cgi script (make sure it is CHMOD 755), clear all the data files (ensure CHMOD 777), and see if it works again.
You can download your existing guestbook data file(s) to a temporary location, then possibly replace them if the script works.
If you get it going, you could try a kludge to stop the problem again (although it might have other strange effects):-
immediately before line 115
$currentpage = ($FORM{'start'} + $entriesperpage + 1) / ($entriesperpage + 1);
add a new line:-
if ($entriesperpage<0) {$entriesperpage=0}
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.