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
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Thu Nov 16, 2006 2:44 am
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?
aaronhall
DevNet Resident
Posts: 1040 Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:
Post
by aaronhall » Thu Nov 16, 2006 4:35 am
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.
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Thu Nov 16, 2006 6:54 pm
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...
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu Nov 16, 2006 7:12 pm
Try
Code: Select all
echo "<div>Please wait..</div>\n"; flush()or another block element, not just plain test.
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Thu Nov 16, 2006 7:23 pm
That didn't work...
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu Nov 16, 2006 7:30 pm
strange, it usually does.
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Thu Nov 16, 2006 7:33 pm
I am using a windows server... Does that matter?
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu Nov 16, 2006 7:35 pm
no.
But maybe there's some other buffer active that flush() doesn't reach. Can't tell from this side.
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Thu Nov 16, 2006 7:42 pm
I've got an ob_start(); and an ob_end_flush() at the top and bottom of the page...
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Thu Nov 16, 2006 7:57 pm
Ok, mystery solved. It's all buffered, not sent to the client.
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Thu Nov 16, 2006 8:15 pm
I put ob_start() in to stop the headers already sent messages... Is there another way to stop those and make the flush work?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Nov 16, 2006 8:18 pm
viewtopic.php?t=1157 should be of interest.
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Thu Nov 16, 2006 8:19 pm
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.
Mr Tech
Forum Contributor
Posts: 424 Joined: Tue Aug 10, 2004 3:08 am
Post
by Mr Tech » Thu Nov 16, 2006 8:27 pm
Sheesh... I wish someone had told me that before I started doing it... Thanks
Luke
The Ninja Space Mod
Posts: 6424 Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA
Post
by Luke » Thu Nov 16, 2006 8:29 pm
No problem... it's one of the most common of php's bad practices.