Jump to content

PHP expert needed with solution.


marksponge02

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
Link to comment
https://forums.phpfreaks.com/topic/9943-php-expert-needed-with-solution/
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.
[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]
[!--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.
[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]

Archived

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

×
×
  • Create New...

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.