ankhmor Posted July 13, 2007 Share Posted July 13, 2007 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 More sharing options...
trq Posted July 13, 2007 Share Posted July 13, 2007 However when it is put in a neverending loop it doesn't work anymore. Never ending loops are to be avoided, what exactly are you trying to do? Link to comment https://forums.phpfreaks.com/topic/59759-script-doesnt-work-if-used-in-a-loop/#findComment-297042 Share on other sites More sharing options...
teng84 Posted July 13, 2007 Share Posted July 13, 2007 here are the lop while($test != $info[0]){ // be sure that in some point the condition here will not be satisfy while($a > $b ){// where did you increment $b so the a is lessthan b that will stop the loop Link to comment https://forums.phpfreaks.com/topic/59759-script-doesnt-work-if-used-in-a-loop/#findComment-297049 Share on other sites More sharing options...
ankhmor Posted July 13, 2007 Author Share Posted July 13, 2007 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. Link to comment https://forums.phpfreaks.com/topic/59759-script-doesnt-work-if-used-in-a-loop/#findComment-297058 Share on other sites More sharing options...
ankhmor Posted July 13, 2007 Author Share Posted July 13, 2007 Anyone? Sorry but this is really urgent. ??? Link to comment https://forums.phpfreaks.com/topic/59759-script-doesnt-work-if-used-in-a-loop/#findComment-297446 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.