Well, first of all, I can see nothing that would add the line; you've got an UPDATE, but UPDATE doesn't add records to a table, only changes the ones that are already there (the UPDATE in question will change every single record in the table, because it has no WHERE clause). My guess would be that that should be an INSERT.
There are a few other syntactic wobblies there as well.
[code=php]
<?
if (getenv ("HTTP_X_FORWARDED_FOR")) {
$ip = getenv ("HTTP_X_FORWARDED_FOR");
} else {
$ip = getenv ("REMOTE_ADDR");
}
$lastline = exec( "ping $ip", $resultsArray );
for($i=0; $i < sizeof($resultsArray); $i++)
{
echo "$resultsArray[$i] . '<br>'";
}
include('dbinfo.inc.php');
$query = mysql_query("SELECT `count`,ip FROM counter WHERE ip='$ip'") or die(mysql_error());
$rows = mysql_num_rows($query);
$what = mysql_fetch_array($query);
$cnt = $what['count'];
$ip = $what['i'];
if($rows == 1){
mysql_query("UPDATE counter SET count=count+1 where ip='$ip'") or die(mysql_error());
echo " ".($cnt+1)." $ip";
}
else
{
mysql_query("INSERT INTO counter (`count`,ip) VALUES (1,'$ip')") or die(mysql_error());
echo ' 1 '.$ip;
}
?>