i wudn't use that, cause it will do that aswell when the same person goes there over and over again...
i made a seperate mysql table for it:
$ip = $REMOTE_ADDR;
mysql_pconnect("localhost", "$mysql_user", "$mysql_pass");
$gethits = mysql_db_query("$mysql_dbname", "select * from views WHERE imgid='$id' AND ip='$ip'");
if(mysql_num_rows($gethits) == 0) {
$ip = mysql_escape_string($ip);
$imgid = mysql_escape_string($imgid);
$link = mysql_pconnect("", "$mysql_user", "$mysql_pass")
or die("unable to connect to mysql server: ".mysql_error());
mysql_select_db('$mysql_dbname')
or die("unable to select database: ".mysql_error());
$query = mysql_query("INSERT INTO views (imgid, ip) VALUES ('$imgid', '$ip')", $link);
if (!$query) {
die("query failed: ".mysql_error());
}
}