尝试从数据库获取地址并写入数组,但总是说Bad,所有服务器都可用。
include('config.php');
$query_select = "select `ip` from `server`";
$result_select = mysql_query($query_select);
$host=array();
while($row = mysql_fetch_array($result_select,MYSQL_ASSOC))
{
foreach ($row as $r){
$host[$r] = $r;
}
}
foreach ($host as $h){
$waitTimeoutInSeconds = 1;
if($fp = fsockopen($h,$waitTimeoutInSeconds)){
echo 'good';
} else {
echo 'bad';
}
fclose($fp);
}