problema risolto posto lo script
<?php
session_start()
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>contatore</title>
</head>
<body>
<?php
//ora attuale
$actualhours = date('H');
// ora scadenza sessione
$endhours = $actualhours + 23;
//recupero l'ip dell'utente
$ipadress = $_SERVER['REMOTE_ADDR'];
//creo la mia connessione al db
$nomeserver = "localhost";
$username = "rbrtone81";
$password = "rbr81altervista";
$dbname = "my_rbrtone81";
$tablename = "count";
$myconn = mysql_connect($nomeserver);
$mydb = mysql_select_db($dbname,$myconn);
//inserisco nel db l'ip del visitatore
$my_sql1 = "INSERT INTO $tablename (ipadress) VALUES ('$ipadress')";
//controllo se nel db è gia presente l'ip dell'utente
$my_sql2 = "SELECT * FROM $tablename WHERE ipadress LIKE ('$ipadress')";
$myquery2 = mysql_query($my_sql2,$myconn);
$myquery1 = mysql_query($my_sql1,$myconn);
$myvalues = mysql_fetch_array($myquery2);
$ipadressdb = $myvalues['ipadress'];
// se l'utente non ha mai visitato il sito ...
if ($ipadressdb == NULL){
$_SESSION['ora'] = $actualhours;
$fp = fopen('count.txt', 'r+');
$file = file('count.txt');
$conta = $file[0]+1;
fwrite($fp, $conta);
echo "sei il visitatore n°: ".$conta;
fclose($fp);
}
//se invece lo ha visitato
else {
$ora = $_SESSION['ora'];
if ($ora > $endhours){
unset($_SESSION['ora']);
$_SESSION['ora'] = $actualhours;
$fp = fopen('count.txt', 'r+');
$file = file('count.txt');
$conta = $file[0]+1;
fwrite($fp, $conta);
echo "sei il visitatore n°: ".$conta;
fclose($fp);
} else {
$fp = fopen('count.txt', 'r');
$legge=fread($fp,filesize("count.txt"));
echo "ci si rivede
";
echo "sei il visitatore n°: ".$legge;
fclose($fp);
}
}
mysql_close($myconn);
?>
</body>
</html>
è un pò cambiato dal precedente ma funziona

Rispondi quotando