"The page cannot be displayed" error. Timeout?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ruth
Forum Newbie
Posts: 19
Joined: Wed Aug 07, 2002 9:24 pm
Location: Melbourne, Australia

"The page cannot be displayed" error. Timeout?

Post by ruth »

Hi everyone,
I have a script that exports records from MySQL to a csv file. The csv file has about 1 million rows. I estimate that script runs up to 5 minutes, so I use set_time_limit() to set time limit. I tried 10 to 20 minutes, and even tried set_time_limit(0). However, how long the time limit I set, I always got "The page cannot be displayed" error after 2 minutes. I checked max_execution_time. It is set to 30. I run out ideas now :oops: . Your help is highly appreciated.

By the way, the script works fine when I cut the number of records.

Thank you in advance
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Perform it in portions.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"The page cannot be displayed" is a browser choice, not the server's. If PHP responds, in some fashion, it renders a completely blank page if nothing else.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

feyd wrote:"The page cannot be displayed" is a browser choice, not the server's.
Would that be why Safari shows that page more than Firefox? :P
ruth
Forum Newbie
Posts: 19
Joined: Wed Aug 07, 2002 9:24 pm
Location: Melbourne, Australia

Post by ruth »

Thank you for your replies. I tried this script using Firefox, and had the same error message at the same time (2 minutes). I can break the records into portions. However, I would like to know why set_time_limit does not have effect.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ruth wrote:Thank you for your replies. I tried this script using Firefox, and had the same error message at the same time (2 minutes). I can break the records into portions. However, I would like to know why set_time_limit does not have effect.
The browser hasn't received feedback, or enough feedback, from the server to tell it more. The browser is simply giving up on waiting for a response.

The script continues to run regardless of the browser waiting for data or not.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Maybe if you randomly echo "Processing..." to the screen or something....
ruth
Forum Newbie
Posts: 19
Joined: Wed Aug 07, 2002 9:24 pm
Location: Melbourne, Australia

Post by ruth »

I tried to echo "wait ..." out, but nothing comes to the screen. I used ob_flush() and flush().
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Servers often have their own output buffer. "Wait..." repeated a few times may not fill it up enough for it to begin sending data.

I would reconsider your approach on this. For lengthy operations I often ask for an email address they can be contacted at. The end of the script will then notify the user when and where their data can be picked up, and for how long it will remain available. In other implementations I've had the script email the finished file, provided it was under a certain size.
ruth
Forum Newbie
Posts: 19
Joined: Wed Aug 07, 2002 9:24 pm
Location: Melbourne, Australia

Post by ruth »

I posted this thread a week ago. After received all your opinions, I spent days to work on this, and finally solved the problem. I post my solutions here in case any one else is in the same situation.

I have two solutions:
1. Send a message every 5 seconds to the browser using ob_flush() and flush(). You will need to set output_buffering to be very small (I set 2). However, I found ob_flush() and flush() will not work with an interactive feature on the page.
2. Using command line (php or wget) to run the script. However, as users do not have an access to the command line, I set up a cron job for the script to run.

Thank you for all your help.
Ruth
Post Reply