iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-16-2008, 09:09 PM
WebProWorld Member
 
Join Date: Nov 2006
Location: Seattle
Posts: 64
shannonlp RepRank 0
Default PHP output while script is running

Does any know how to show the status os a PHP script while the script is still running.

I only need to make this work using FF. It is a backend script. The script can take several minutes to parse. It is essentially a bot parsing large amount of text and adding results into a database.

Something like this:

Extraction Started.....
then
Looking for matches.....
then
Creating Array.....
then
etc.....

I have played with flush() and ob_flush(). They only show the results after the script is fully completed. I would like the results not necessarily line by line but module by module.

Any Ideas?
__________________
Web Designer and Custom Spider Creator
eCommerce and shopping cart information
Reply With Quote
  #2 (permalink)  
Old 10-17-2008, 12:30 AM
WebProWorld Member
 
Join Date: Nov 2006
Location: Seattle
Posts: 64
shannonlp RepRank 0
Default Re: PHP output while script is running

I don't think that will work!!
__________________
Web Designer and Custom Spider Creator
eCommerce and shopping cart information
Reply With Quote
  #3 (permalink)  
Old 10-17-2008, 09:35 AM
DaveSawers's Avatar
WebProWorld Veteran
 
Join Date: Dec 2006
Location: Calgary, Alberta, Canada
Posts: 492
DaveSawers RepRank 3DaveSawers RepRank 3
Default Re: PHP output while script is running

I expect those unrelated posts will be removed by a moderator in due course.

Anyway, back to the question.

Simplest solution is to break your script into separate modules and execute them sequentially via AJAX calls. That way, each part can report back upon completion. Using AJAX means you don't have to refresh the entire page after each module, just add information to the progress.
__________________
Dynamic Software Development
www.activeminds.ca
Reply With Quote
  #4 (permalink)  
Old 10-17-2008, 11:06 AM
wige's Avatar
Moderator
WebProWorld Moderator
 
Join Date: Jun 2006
Location: United States
Posts: 2,648
wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9wige RepRank 9
Default Re: PHP output while script is running

I have a PHP script that has to cycle through XML feeds containing hundreds of thousands of elements once a month. I use the same basic methodology you are looking for where it outputs a '.' each time it processes an XML element so I know the script hasn't died. The basic code is the following:

echo '. ';
if ($a % 10 == 0) {
ob_flush();
flush();
}

You can remove the if and closing brace lines so it will force output to the browser after each individual '.'. In my case, outputing the dots in groups of ten is sufficient.

In my case, AJAX calls wouldn't work because the script needs to also be executed by the operating system and by wget and cron.
__________________
The best way to learn anything, is to question everything.
Reply With Quote
  #5 (permalink)  
Old 10-17-2008, 07:28 PM
WebProWorld Member
 
Join Date: Nov 2006
Location: Seattle
Posts: 64
shannonlp RepRank 0
Default Re: PHP output while script is running

wige

You nailed it. Got it figured out about an hour after making the post.

I thought AJAX at first. The problem with AJAX is you would have to open a HTTP stream for this to work. This would cause for resource issues during heavy traffic.

The script will be used for on the backend of the site. It could still impact the frontend resources.

I did find that I had to make modifications which are covered under flush() @ php.net. Mods included things like verify INI file, virus software, etc... Anything that could potentially buffer content.

Anyways thanks for the help!
__________________
Web Designer and Custom Spider Creator
eCommerce and shopping cart information
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PR Update is running govindseo Google Discussion Forum 10 09-30-2008 11:44 PM
Getting out of the rat race and running it alone... Graf1771 Marketing Strategies Discussion Forum 35 04-29-2007 05:14 PM
Persistent Data: File Input and Output WPW_Feedbot Graphics & Design Discussion Forum 0 08-25-2005 11:04 AM
XML Output MidNite Flash Discussion Forum 1 12-12-2004 02:06 PM
PHP field - output a URL from Admin area? cyberious Web Programming Discussion Forum 1 01-09-2004 03:18 PM


All times are GMT -4. The time now is 05:28 AM.



Search Engine Optimization by vBSEO 3.3.0