Jump to content

Script doesn't work if used in a loop


ankhmor

Recommended Posts

I have a script that works perfectly (I run it in Linux in terminal(bash));

However when it is put in a neverending loop it doesn't work anymore. What it does it works once and then doesnt work properly.

I added echo "executing.." so I whould know if the scripts is working. It show excecuting... but the rest of the script doesn't work.

 

Someone help please.

 

Oh and heres the script (without the neverending loop);

 

mysql_connect("localhost", "root", "new-password") or die("Couldnt connect");
mysql_select_db("profiles") or die("Couldnt select");
echo "excecuting ...";
$array = file("http://oh2aq.kolumbus.com/dxs/dx250.html?");
$last = mysql_query("SELECT `id`, `call` FROM `list` ORDER BY id DESC LIMIT 1") or die(mysql_error()."\nline 8");
$a = 1;
$count = count($array) - 2;
$test = mysql_result($last, 0, 'call');
while($test != $info[0]){
$info = preg_split("/ /", $array[$a], -1, PREG_SPLIT_NO_EMPTY);
$a++;
}
$b = 0;
$a = $a - 2;
while($a > $b ){
		$info_2 = preg_split("/ /", $array[$a], -1, PREG_SPLIT_NO_EMPTY);
		$comments = explode ("\n", chunk_split($array[$a], 30, "\n"));
		$comment = str_replace("'", '"', $comments[1]);
echo $info_2[0]."|--|".$info_2[1]."|--|".$info_2[2]."|--|".$comment."|--|".$a."\n";
mysql_query("INSERT INTO `list` (`call`, `frequency`, `other_call`, `comments`) VALUES ('$info_2[0]', '$info_2[1]', '$info_2[2]', '$comment')") or die(mysql_error()."\nline 25");
$a--;
}
mysql_close();

Link to comment
https://forums.phpfreaks.com/topic/59759-script-doesnt-work-if-used-in-a-loop/
Share on other sites

What im trying to do is to get data from a website (it is perfectly legal because it is a special type of website (radion fan one));

And I must do it continiously or every 3 minutes.

Because I cant run html in Linux bash i want to put my script in continuous loop.

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.