Page 1 of 1

PHP tries to download file

Posted: Fri Jun 01, 2007 6:25 pm
by John Cartwright
I've run into a rather weird issue, I'm working on a script that fetches an XML document for processing, using SimpleXMLElement. After about 10 seconds the script is terminating and I am getting the download dialogue to try and download the script, as if php is not being intepreted at all. The odd thing about this is that this that the script will execute fine sometimes, others am I running into this problem.

Currently I am using file_get_contents() to fetch the xml document, which seems to be causing the problem. I have also tried inputting the request url directly to the SimpleXMLElement object, with the same results.

I take it the request is timing out and borking PHP. If the connection is timing out, I do not understand why it gives me download dialogue. I have tried using

Code: Select all

set_time_limit(0);
ini_set('memory_limit', '32mb');
ignore_user_abort();
Although I don't see how that would help, it was worth a try. The XML document I am fetching is rather small, and when working it only takes about 3 seconds to fetch the XML document (found on another server).

Any thoughts?

Posted: Fri Jun 01, 2007 8:01 pm
by maliskoleather
im not too sure if this will help... buuuuuuut, I had a simmilar issue not too long ago... I was retrieving a file from another machine on the local network, and every now and then it would time out and cause the browser to attempt to download the file.

I think what was happening was that the server delay caused php to fail in the content-type header. I'm not too sure if this is a bug in PHP... i just assumed something was wacky on my server.. lol

the only way i could get it to work was to make my own timeout script... and have it throw an error and die after 20 seconds or so. Every time i tried using PHP's script timeout on that particualr function, it went goofy.