kdavidm
asked on
PHP and run 2 scripts
I would like to have a background script running that will run continuously but am having problems in trying to get it working, if it is possible. Basically a user submits a form and it'll load two scripts, one background script and one foreground script. I tried using frames to do it, with the background script in one frame and a foreground script in another frame. But if the background script runs continuously in the first frame the second frame which contains the foreground script can never get processed. Also the foreground script will refresh probably about every 30s or so and I am using meta tags to do it. So how can I have a background script continuously running and also have the foreground script be processed as well?
ASKER
The background script just gets updates from user interaction and communication then stores the data in a database, the foreground script reads in these updates from the database and outputs them every 30s for example. Yes I know it isin't very efficient and yes there are better and more simpler ways to do it without using PHP, but I want to use PHP to do it. So I would like to know if it's possible to have two scripts running, one background continuously and one foreground.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
PHP script ends the moment it is relivered to the client and no way to leave it running. Maybe you can use php-java integration, haven't tried it my self, but have a look at that link
http://www.php.net/manual/en/ref.java.php
http://www.php.net/manual/en/ref.java.php
Try to take a look PHP command line
PHP-CLI (Command Line Interface), may it can work for your case.
PHP-CLI (Command Line Interface), may it can work for your case.
A useful tutorial may be
http://www.phpfreaks.com/tutorials/86/1.php
http://www.phpfreaks.com/tutorials/86/1.php
Not entirely sure what it is that you are trying to do. What are these scripts actually going to be doing? Particularly, what is the script that you want to be running continuously? Since PHP is server side.. I'm not sure what the background script could actually be doing that would require it to be running indenfinitely.