lynxus Posted December 23, 2009 Share Posted December 23, 2009 Hi Guys, I have the below: ( Snippet of offending code ) Basically it should do this: - at the top, it does a while from the restult of a main sql query ( this works ) - It then (inside the while) does anyother sql query to see if that row is already in the DB ) - If it isnt, then it should insert it. - If it is, Then do nothing. Problem: I get the output from the echo VRFname bit but the internal while doesnt seem to happen. It doesnt echo "doing while " or the Interting echo or even the This vrf is already .. echo. It just doesnt look like the while inside the while is happening... Any thoughts? ( Its early and my brain is dead ) while($row = mssql_fetch_array($result)) { $vrf = $row["VRF"]; $rd = $row["RD"]; echo " VRFname: " . $vrf; echo "\n"; echo " RouteD: " . $rd; echo "\n"; $lquery = "select rd from vrf where rd = '$rd'"; $lresult = mysql_query($lquery); while($lrow = mysql_fetch_array($lresult)) { echo "Doing while \n"; $lrd = $lrow['rd']; if ($lrd != "") { echo "Inserting VRF as this didnt exist \n"; mysql_query("INSERT INTO vrf (vrf, rd, lingertime) VALUES('$vrf', '$rd', '3' ) ") or die(mysql_error()); // if rd }else{ echo "This VRF is already in the table \n"; } // Internal while mysql loop } //End main while } //close the connection mssql_close($dbhandle); Link to comment https://forums.phpfreaks.com/topic/186131-problem-with-while-loop/ Share on other sites More sharing options...
lynxus Posted December 23, 2009 Author Share Posted December 23, 2009 Resolved Link to comment https://forums.phpfreaks.com/topic/186131-problem-with-while-loop/#findComment-983026 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.