the scripts restarts itself?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
folo
Forum Newbie
Posts: 5
Joined: Wed Jul 21, 2010 7:57 am

the scripts restarts itself?

Post by folo »

I have a problem with a script that restarts itself after about 5 minutes or about 1000 url's crawled. It basically crawls url's and collects information, and after a while it simply restarts the main script. I have no idea why it does this.

<?php

include 'down_parse.php';
include 'static/config.php';
include 'static/opendb.php';

$result2 = mysql_query("SELECT Application_XML_File_URL FROM padentries");
if (!$result2) { echo 'Could not run query: ' . mysql_error(); exit; }

while ($row = mysql_fetch_array($result2)) {
$nn++;
echo "$nn. <b>". $row["Application_XML_File_URL"] ."</b> - ";
psite($row["Application_XML_File_URL"]);
}

mysql_close($conn);

?>

As you can see the variable $nn autoincrements itself for each url crawled. But after a while the entire script refreshes itself, clears the results on the screen and $nn starts over from 1.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: the scripts restarts itself?

Post by Jade »

What's in your include down_parse.php and config.php files?
folo
Forum Newbie
Posts: 5
Joined: Wed Jul 21, 2010 7:57 am

Re: the scripts restarts itself?

Post by folo »

In the those files are the connection to teh database and the code for actually crawling and parsing the sites.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: the scripts restarts itself?

Post by Jade »

My guess is that you have a redirect somewhere in those files that's causing the problem thats why I asked to see them.
folo
Forum Newbie
Posts: 5
Joined: Wed Jul 21, 2010 7:57 am

Re: the scripts restarts itself?

Post by folo »

Nope, thats what is so puzzeling, there are no redirects or anything like that at all anywhere in the code of any of the scripts.
It seems be something else, like if a script executes for a very long time the browser assumes its hung and reloads it or something like that? Or the script restarts itself because its been running for "too long" something like that?
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: the scripts restarts itself?

Post by Jade »

I've never heard of anything like that but I wouldn't totally scratch it as a possibility. What browser are you using to run it?
folo
Forum Newbie
Posts: 5
Joined: Wed Jul 21, 2010 7:57 am

Re: the scripts restarts itself?

Post by folo »

IE
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: the scripts restarts itself?

Post by Jade »

What you need to do is use Firefox and install the firebug add on https://addons.mozilla.org/en-US/firefox/addon/1843/

Open the firebug console and then run your script. If something is re-starting it you'll be able to see what in the console section. For all you know it could be something as stupid as some kinda spyware you aren't aware of thats running in the background. Either way firebug will show you the headers being sent out.
folo
Forum Newbie
Posts: 5
Joined: Wed Jul 21, 2010 7:57 am

Re: the scripts restarts itself?

Post by folo »

Thanks! I'll give it a go.
Post Reply