Hi me again, im starting to get VERY annoyed with my script.
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 )
Code:
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);