/    Sign up×
Community /Pin to ProfileBookmark

Can I run a bunch of php pages off a single page?

I’m a bit confused on how to do this.

Basically I have a bunch of various php import pages. I want to create a single page that will have a link/button/whatever to start and it will start off the first php import… once that is finished it would send a signal back to the start page and it would then move onto the second, etc. until the process is finished.

However, even if one of the import pages were to freeze up or whatever it should still continue on with the rest of the pages. I’m not sure exactly how it would determine whether another page froze up… I have time estimates on each import so I guess I could make it so that if the main page doesn’t get a signal within a certain amount of time (estimate + healthy buffer,) it just moves on? This is the main reason I think the main page needs to stay active while the php import pages are going… otherwise it would be pretty easy I think, to just have the main page start things off and each one could move right to the next one.

Another thing is IF the main page stays active, it would have to be using minimal resources, as the imports are pretty hefty on the resources.

Any ideas?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@SyCoNov 19.2008 — The simplest way is to include the files but errors could bring the parent script to a halt.

cURL might be a better fit. It can return the response from another script or even a remote web page to a variable. The string can be parse for the appropriate failure/success variable from the cURLed scripts.

Here are a couple of examples the first allows for additional POSTed vars and the second uses GET

[code=php]<?php
set_time_limit (120) ;//increase the max execution time for this script only, if required


// find books on php and mysql on amazon
//POST
$url = "http://www.amazonqwe.com/exec/obidos/search-handle-form/002-5640957-2809605";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 25); //set times out
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "url=index&#37;3Dbooks&field-keywords=PHP+MYSQL"); // add POST fields
$result1 = curl_exec($ch); // run the whole process
curl_close($ch);
//echo $result1;

// find books on php and mysql with google
//GET
$url2 = "http://www.google.com/search?hl=en&q=php+books";
$ch2 = curl_init(); // initialize curl handle
curl_setopt($ch2, CURLOPT_URL,$url2); // set url to post to
curl_setopt($ch2, CURLOPT_FAILONERROR, 1);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch2, CURLOPT_TIMEOUT, 25); //set times out
$result2 = curl_exec($ch2); // run the whole process
curl_close($ch2);
//echo $result2;

//parse $result1 and $result2 for success/failure messages

?>
[/code]
×

Success!

Help @xvszero spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...