Jump to content


Photo

PHP expert needed with solution.


  • Please log in to reply
9 replies to this topic

#1 marksponge02

marksponge02
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 18 May 2006 - 05:52 PM

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

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 18 May 2006 - 05:53 PM

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

Info: PHP Manual


#3 marksponge02

marksponge02
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 18 May 2006 - 05:58 PM

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 :)

#4 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 18 May 2006 - 06:02 PM

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.

Info: PHP Manual


#5 marksponge02

marksponge02
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 18 May 2006 - 06:06 PM

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.

#6 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 18 May 2006 - 06:25 PM

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.

Info: PHP Manual


#7 marksponge02

marksponge02
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 18 May 2006 - 06:26 PM

Thread bookmarked :)

Thanks ober.

#8 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 18 May 2006 - 06:32 PM

So there is no way of running a server side script without using a browser, manual command promt or cron job?

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.
]$ php /file/path/to/script.php


#9 marksponge02

marksponge02
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 18 May 2006 - 06:41 PM

[!--quoteo(post=375015:date=May 18 2006, 12:58 PM:name=MarkSponger)--][div class=\'quotetop\']QUOTE(MarkSponger @ May 18 2006, 12:58 PM) View Post[/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.

#10 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 18 May 2006 - 07:11 PM

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.

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.

You can use PHP from the command line, running the script yourself or using a cronjob.

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.
php /path/to/file.php &> /dev/null &





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users