Jump to content

Archived

This topic is now archived and is closed to further replies.

marksponge02

PHP expert needed with solution.

Recommended Posts

I have a website that deals with lots of information.

At the moment I have apage that builds an excel spreadsheet using information from my mysql database.

This is ok with small amounts of data, it shows a blank page while it builds the report. I am having trouble with large amounts of data. The report can take up to 2 hours to be built and if I close the browser window the report doesn't get built.

I have seen sites where you can set a report going and close all browser windows then recieve an email when the report is ready.

How can I do this?

I know how to send emails and save files to the server but how do I do it if the user closes the browser window?

To sum up: How do I set a PHP script running where if the user closes the browser window the script continues to run until it finishes?

Thanks in advance.

Mark

Share this post


Link to post
Share on other sites
Chances are they're not using PHP to do that. They're firing off some system-based software that builds the report for you.

Share this post


Link to post
Share on other sites
So there is no way of running a server side script without using a browser, manual command promt or cron job?

Can I not post to a hidden page?

Just guessing now :)

Share this post


Link to post
Share on other sites
I don't honestly know to tell you the truth, but I'm about 96% sure that calling a PHP script via webbrowser would pretty much kill it if you just decided not to provide a return path for the results.... that may not be an exactly accurate description of why it would die, but I can't come up with the right wording at the moment.

It can't hurt to try, but it appears that you've done that, without a positive result.

Share this post


Link to post
Share on other sites
OK thanks for the help anyway.

You don't happen to know any server based software packages with this capability do you?

I've googled it with not much success.

Share this post


Link to post
Share on other sites
Not off the top of my head. And I'd keep an eye on this thread if I were you. There are a few other members on here that probably have some experience in this arena that may be able to help you out.

Share this post


Link to post
Share on other sites
[quote]
So there is no way of running a server side script without using a browser, manual command promt or cron job?
[/quote]
If this is something you want to run manually whenever you choose, then you can run it via the command prompt. You can [a href=\"http://www.php.net/manual/en/features.commandline.php\" target=\"_blank\"]use PHP from the command line[/a], running the script yourself or using a cronjob.

If no user input is required and no APACHE variables are used, then you can run the script as is.
[code]
]$ php /file/path/to/script.php
[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=375015:date=May 18 2006, 12:58 PM:name=MarkSponger)--][div class=\'quotetop\']QUOTE(MarkSponger @ May 18 2006, 12:58 PM) [snapback]375015[/snapback][/div][div class=\'quotemain\'][!--quotec--]
So there is no way of running a server side script without using a browser, manual command promt or cron job?
[/quote]

Thanks for your help but I already explored that avenue.

I need to set the report going in a web browser and leave it going.

Unless I want to write my own linux app I think I'll use cron jobs and mysql.

Share this post


Link to post
Share on other sites
[quote]
Thanks for your help but I already explored that avenue.

I need to set the report going in a web browser and leave it going.

Unless I want to write my own linux app I think I'll use cron jobs and mysql.
[/quote]
I've tried to understand, but I still don't follow. If you're going to run this using a cronjob you should be able to run it manually using bash or similar shell. There's no need to write a linux app. Look at the page I linked to above for more info on running php via the command line.

Using a cronjob was mentioned btw.
[quote]
You can use PHP from the command line, running the script yourself or using a cronjob.
[/quote]
If you have to start the script using a browser then to run it in the background you can try using one of the program execution functions such as [a href=\"http://www.php.net/manual/en/function.exec.php\" target=\"_blank\"]exec[/a] and put the process in the background. Again however, you'll need to run the script using the php binary.
[code]
php /path/to/file.php &> /dev/null &
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.