Строки
_username_,
_password_,
_database_,
_Primer_,
_row_ замените на свои фактические значения/параметры.
$DB = mysqli_connect("localhost", "_username_", "_password_", "_database_") or die(mysqli_error($DB));
function ping($IP)
{
global $DB;
if (!preg_match("/^(\d{1,3})(\.\d{1,3}){3}$/", $IP)) return false;
exec('ping -c 2 -i 0.2 ' .$IP,$ping);
$nachalo = substr($ping[1],0,4);
if ($nachalo !== "From")
{
mysqli_query($DB, "INSERT INTO _Primer_ (_row_) VALUES(1)") or die(mysqli_error($DB));
}
else
{
mysqli_query($DB, "INSERT INTO _Primer_ (_row_) VALUES(0)") or die(mysqli_error($DB));
}
}