I am trying to get a script to work. The basic idea is to go into a database and grab some IP addresses for my LAN. Then for each one ping it using the exec command 1 time. If it is successful print output in green and if it is not, print output in red. This is being done on a Win32 system. The ping command returns 6 lines for each IP address. I want to take line 4 and see if the result is "100% loss" or "0% loss". Below is what I have, but it only seems to keep the first value and prints it out all the way through. I know it's a problem with the looping somewhere, I just can't figure it out.
<?php mysql_connect("localhost", "root", "") or die("Could not connect"); mysql_select_db("Network"); $Result = mysql_query("SELECT DISTINCT Subnet,SerialIPAddress FROM Locations") or die("Invalid query"); $output = array(); while ($Location = mysql_fetch_assoc($Result)) { // ping some server five times and store output in array $output exec("ping " . $Location["Subnet"] . " -n 1", $output); $Count = 0; while (list(,$val) = each($output)) { if($val != "") { $Count++; print "$Count - $val<br>\n"; if($Count == 4) { list($Junk1, $Results1) = split("\(", $val); list($Results2, $Junk2) = split("\)", $Results1); if($Results2 = "100% loss") { print "<font color=\"red\">$Results2</font><br>\n"; } else { print "<font color=\"green\">$Results2</font><br>\n"; } } } } print "<hr>\n"; } mysql_free_result($Result); mysql_close(); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php