I'm having trouble with a script dying on me at inopportune moments. The script's death doesn't give any clues as to why. In Opera, it just does nothing for about a minute and then brings up the download dailog box with the script's (email.php) as the filename. It downloads a 0 byte file if I follow through. In Firefox, nothing happens and the connection dies in a few seconds. In MSIE, the error page "The page cannot be displayed. The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings." appears in just a second or two.
I don't think it's anything directly to do with my script as it's so strange. Below is script specific stuff in case it helps anyway:
I can't post the script here (it's over a thousand lines long) but the general overview is:
Page loads with email ID passed as get argument
It created an object based off a long email class I wrote (most of the script is this class).
It figures out a loadof details to do with the email such as attachments, embedded emails and so on.
It displays the email and offers links for downloading attachments.
This script doesn't do this all the time, just on some of the emails that I pass to it. I can't see a pattern to the failing ones. Sometimes a passed email does work but then breaks - I just had one break. The only change was that I added 1 to the return value of a function! I changed $pId = substr($bodyId, strrpos($bodyId, ".")) - 1; to $pId = substr($bodyId, strrpos($bodyId, ".") + 1) - 1;. Removing the change allows that email to work again. That something this trival breaks it leads me to believe it's not directly my script, but something like a memory problem.
I've tried putting echo statements at the top of the page and the class contructor to see if I get any output. I don't. The same problem occurs on a commercial host with Linux / Apache 1.3.31 / PHP 4.3.9 and on my development server with Windows / Apache 2.0.52 / PHP 5.0.1.
I'm at a loss as to where to even start with this problem asside from trying for any output. I've had this problem before but it's always cleared upon continuing the script even after the test fails, which I can't do in this case.
EDIT: I just found a Win2000 machine with IIS. On this, all browsers just sit trying to load the page but get nothing until it times out in about 5 minutes.