mrp101 Posted February 27, 2010 Share Posted February 27, 2010 Hi there. I'm posting a script I've written which reads data from one database and uses it to do a full text search on another database, writing the highest score from the search to the original database. It is working OK except for the fact that it only performs a full loop twice and dies after reading the data into the array on the third pass. I've changed the values in the for loop, but it makes no difference. Any help, suggestions, ideas or otherwise gratefully appreciated. thanks - mrp <HTML> <HEAD> <TITLE>Debug No 5</TITLE> </HEAD> <BODY> <?php // Set the variables for the database access: $Host = "localhost"; $User = "user"; $Password = "password"; $DBName = "dbbname"; $TableName1 = "table1"; $Link = mysql_connect ($Host, $User, $Password); $countx = 0; $Query1 = "SELECT * from $TableName1"; $Result = mysql_db_query($DBName, $Query1, $Link); if($Result) { print ("Connection OK"); } $scores = array(); for ($i=1; $i<=6; $i++){ $Row = mysql_fetch_array ($Result); $t = $Row[T]; $p = $Row[P]; echo($t); echo($p); $Query3 = "SELECT f1, f2, MATCH (f1) AGAINST ('".$t."') AS SCORE FROM table2"; $Result3 = mysql_query ($Query3, $Link); While($Row3 = mysql_fetch_array ($Result3)) { $scores[] = $Row3[sCORE]; echo($Row3[sCORE]."\n"); } $score = max($scores); $Query5 = "UPDATE Table1 SET value = ".$score." WHERE P = '".$P."' AND t = '".$t."' "; mysql_query($Query5, $Link); $scores = array(); } mysql_close ($Link); ?> </BODY> </HTML> Link to comment https://forums.phpfreaks.com/topic/193562-simple-i-hope-problems-with-nested-control-loops/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.