Lo he continuado un poco y he arreglado un par de cosillas pero ahora me analiza 2 filas ( 6 y 5 ) i me tira este error
Fatal error: Cannot redeclare ping() (previously declared in C:\xampp\htdocs\XX.php:17) in C:\xampp\htdocs\XX.php on line 17
<?php
$conexion = mysql_connect("localhost", "admin", "patapam");
mysql_select_db("pert", $conexion);
/* COMPROBAR LA CANTIDAD DE SERVERS QUE HAY */
$totalserversquery = mysql_query("SELECT * FROM `servers` WHERE `banned` = 0 AND `deleted` = 0 ORDER BY `id` DESC");
$totalservers = mysql_num_rows($totalserversquery);while ($totalservers = mysql_fetch_array($totalserversquery))
{
echo 'El dato es: '.$totalservers['id'].'<br />';
echo 'El dato es: '.$totalservers['host'].'<br />';
echo 'El dato es: '.$totalservers['puerto'].'<br />';
/*COMPROBAR SI LA WEB ESTA ON */
$site = $totalservers['host'];
$puerto = $totalservers['puerto'];
$timeout= 6;
$si = -1;
$no = +5;
function ping($site,$puerto,$timeout)
{
@$fsock = fsockopen($site, $puerto, $errno, $errstr, $timeout);
if ( ! $fsock )
{
return FALSE;
}
else
{
return TRUE;
}
}
/* mirar si el host funciona */
$up = ping($site,$puerto,$timeout);
if ($up == TRUE)
{
mysql_query("UPDATE servers SET WHERE banned = 0 (mindown, on) VALUES ('.$si.','0')");
}
else
{
mysql_query("UPDATE servers SET WHERE banned = 0 (mindown, on) VALUES ('.$no.','0')");
}
/*cALCULAR EL UPTIME */
$num1 = 43200;
$num2 = 100;
$al1 = $totalservers['mindown'] / $num1;
$al2 = $al1 * $num2;
$totalup = 100 - $al2;
mysql_query("UPDATE servers SET online = $totalup");
}
?>