473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

PHP Program Randomly Stops

Who knows how to do any of the following (1-3)?

1. "You're going to want to run it not through the web server, but via
the command line."

2. "You can use a combination of PHP with client side code to keep the
script running. Set a particular number of pages to be processed, a
number lower than when you experience the timeout. As long as there
are pages to be processed print a client side script, e.g. JavaScript,
to reload the page. This will reload until all pages are done - then
don't output the reloader code."

3. "You are running the script from a browser. The browser receives
output from your PHP script - or waits for it. Send output to the
browser that triggers the reloading of the page. This makes sense when
you invoke (whatever snoopy is) the class a finite number of times,
e.g. 100 URLs at a time. Once the URLs are processed keep track of
the number of processed URLs via a session variable. Then output some
JavaScript to the browser that reloads the page. Here's an example
How do I "print" a client side script?{: print
"<script>document.location.reload();</script>"; Alternatively you can
do it in PHP if you make sure there is no output sent before
redirecting. You could use the header() function to redirect the
script to itself. header("Location: ".$_SERVER['PHP_SELF']);"

Explanation:

I have written a PHP program to retrieve the HTML of web pages, using
class SNOOPY http://sourceforge.net/projects/snoopy to translate the
URL into the HTML. After about 100-300 references to snoopy, which
takes about 5-15 minutes, it stops.

1. I start it using Internet Explorer.
2. There is no error message.
3. The program has no reference to set_time_limit.
4. max_executiontime=0 in php.ini .
5. A program that simply executes an endless for, periodically
printing out the current time, runs indefinitely, which I manually
stopped after 2 hours.
6. I am running it on my single PC window 98 webserver Apache from
PHPTriad http://sourceforge.net/projects/phptriad .

I received the above three answers, but I don't know how to do those
things. I program only in PHP (and HTML.) I couldn't get any further
explanation.

Charlie ch***@aol.com
Jul 17 '05 #1
1 1868
On 29 May 2004 12:45:11 -0700, ch***@aol.com (Charlie-Boo) wrote:
I have written a PHP program to retrieve the HTML of web pages, using
class SNOOPY http://sourceforge.net/projects/snoopy to translate the
URL into the HTML. After about 100-300 references to snoopy, which
takes about 5-15 minutes, it stops.
OK, if you have a script that runs for that long, it's inappropriate for it to
be run within a single HTTP request.
Who knows how to do any of the following (1-3)?

1. "You're going to want to run it not through the web server, but via
the command line."
http://uk.php.net/manual/en/features.commandline.php

For a script that takes 15 minutes, this by far the preferred method.
2. "You can use a combination of PHP with client side code to keep the
script running. Set a particular number of pages to be processed, a
number lower than when you experience the timeout. As long as there
are pages to be processed print a client side script, e.g. JavaScript,
to reload the page. This will reload until all pages are done - then
don't output the reloader code."
Ugh.
3. "You are running the script from a browser. The browser receives
output from your PHP script - or waits for it. Send output to the
browser that triggers the reloading of the page. This makes sense when
you invoke (whatever snoopy is) the class a finite number of times,
e.g. 100 URLs at a time. Once the URLs are processed keep track of
the number of processed URLs via a session variable. Then output some
JavaScript to the browser that reloads the page. Here's an example
How do I "print" a client side script?{: print
"<script>document.location.reload();</script>"; Alternatively you can
do it in PHP if you make sure there is no output sent before
redirecting. You could use the header() function to redirect the
script to itself. header("Location: ".$_SERVER['PHP_SELF']);"


Sounds like a perversion of what HTTP is meant for, but possibly workable as a
last resort. Unnecessarily complicated though; just go for (1).

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: J. Campbell | last post by:
what happens to allocated memory when a program terminates before the memory is released. For example: int main(){ int* array; int a_size = 1000; array = new int; for(int i = 0; i < a_size;...
1
by: Phil S | last post by:
My server is randomly restarting every few minutes or so, and I can't figure out why. What would cause this to happen, aside from some evil person sitting at the console? I did manage to catch it...
0
by: Paul McGuire | last post by:
My son showed me this Flash game, Orbit (there are *many* links on the web out there for it, here's one for the Google-challenged: http://uploads.ungrounded.net/250000/250408_orbit.swf), and it is...
1
by: SamIAm | last post by:
Hi I am getting pretty frustrated here. I have a simple page architecture that consists of a header web user control, the main page content and a footer web user control Every so often that...
9
by: AndersBj | last post by:
Hi all, I have a web application that uses State Server for session handling. The web application randomly loses all session variables. The sessions are not always lost, sometimes I can use the...
6
by: popone | last post by:
Hi All, I've developed a program that seems to crash randomly, from what I can tell it's after some user action. If it just sat there, it wouldn't crash. It's not an exception either, it's the...
9
by: Alan Isaac | last post by:
I need access to 2*n random choices for two types subject to a constraint that in the end I have drawn n of each. I first tried:: def random_types(n,typelist=): types = typelist*n...
1
by: irfath | last post by:
Write an interactive program that reads three (3) lists of numbers, which are stored in three separate files, and creates one (1) sorted list. Each file should contain not more than 15 numbers....
4
by: slapsh0t11 | last post by:
Hello! I need help with a program that I believe I am nearly done with. However, there seems to be a few details that preclude me from success. Here is my assignment: Here is my class file...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.