Page 1 of 2
Loading a PHP page progressively...
Posted: Thu Nov 16, 2006 2:44 am
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?
Posted: Thu Nov 16, 2006 4:35 am
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.
Posted: Thu Nov 16, 2006 6:54 pm
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...
Posted: Thu Nov 16, 2006 7:12 pm
by volka
Try
Code: Select all
echo "<div>Please wait..</div>\n"; flush()
or another block element, not just plain test.
Posted: Thu Nov 16, 2006 7:23 pm
by Mr Tech
That didn't work...
Posted: Thu Nov 16, 2006 7:30 pm
by volka
strange, it usually does.
Posted: Thu Nov 16, 2006 7:33 pm
by Mr Tech
I am using a windows server... Does that matter?
Posted: Thu Nov 16, 2006 7:35 pm
by volka
no.
But maybe there's some other buffer active that flush() doesn't reach. Can't tell from this side.
Posted: Thu Nov 16, 2006 7:42 pm
by Mr Tech
I've got an ob_start(); and an ob_end_flush() at the top and bottom of the page...
Posted: Thu Nov 16, 2006 7:57 pm
by volka
Ok, mystery solved. It's all buffered, not sent to the client.
Posted: Thu Nov 16, 2006 8:15 pm
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?
Posted: Thu Nov 16, 2006 8:18 pm
by feyd
viewtopic.php?t=1157 should be of interest.
Posted: Thu Nov 16, 2006 8:19 pm
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...
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.
Posted: Thu Nov 16, 2006 8:27 pm
by Mr Tech
Sheesh... I wish someone had told me that before I started doing it... Thanks

Posted: Thu Nov 16, 2006 8:29 pm
by Luke
No problem... it's one of the most common of php's bad practices.