Loading a PHP page progressively...

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

User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Loading a PHP page progressively...

Post by Mr Tech »

I have a script that generates a Microsoft Word document.. It takes several seconds to load and while it generates, it displays a blank page...

Is it possibly to display a little "Please wait.." message on the output page while the Microsoft Word document is generating? How?
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Use a page that prints the message and immediately meta-redirects to the document processing script. The 'please wait' page will be displayed until the Word document is loaded.
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

So I'm guessing it's not possible? I found the flush() command that said that it would do what I mentioned in my first post however it didn't work...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Try

Code: Select all

echo "<div>Please wait..</div>\n"; flush()
or another block element, not just plain test.
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

That didn't work...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

strange, it usually does.
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

I am using a windows server... Does that matter?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

no.
But maybe there's some other buffer active that flush() doesn't reach. Can't tell from this side.
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

I've got an ob_start(); and an ob_end_flush() at the top and bottom of the page...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Ok, mystery solved. It's all buffered, not sent to the client.
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

I put ob_start() in to stop the headers already sent messages... Is there another way to stop those and make the flush work?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

viewtopic.php?t=1157 should be of interest.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

I put ob_start() in to stop the headers already sent messages... Is there another way to stop those and make the flush work?
uhh... stop sending output after headers... :roll:

Headers already sent errors happen because you are trying to send headers after output has been sent to the browser... to stop the errors, stop headers after output... it's that simple.

Output buffering is no solution to the headers already sent error... all it does is cover them up and that is terrible practice.
User avatar
Mr Tech
Forum Contributor
Posts: 424
Joined: Tue Aug 10, 2004 3:08 am

Post by Mr Tech »

Sheesh... I wish someone had told me that before I started doing it... Thanks ;)
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

No problem... it's one of the most common of php's bad practices.
Post Reply