addy_010 Posted July 18, 2007 Share Posted July 18, 2007 ok well im stuck trying to add a php counter which i have used times before, but now its not working so come here for some help. this is the code im using <? include ("stats/db.php"); $date = date("M d, Y"); $hitadd= MYSQL_QUERY("INSERT INTO stats(date, ip)". "VALUES ('$date', '$REMOTE_ADDR')"); ?> and to display it <? include ("stats/db.php"); $date = date("M d, Y"); $uniquea = mysql_query("SELECT DISTINCT ip FROM stats"); $uniqueb = mysql_num_rows($uniquea); $tdayua = mysql_query("SELECT DISTINCT ip FROM stats WHERE date = '$date'"); $tdayub = mysql_num_rows($tdayua); $hitsa = mysql_query("SELECT * from stats"); $hitsb = mysql_num_rows($hitsa); $tdayhitsa = mysql_query("SELECT * from stats where date = '$date'"); $tdayhitsb = mysql_num_rows($tdayhitsa); echo ("Total Hits: $hitsb <br /> Total Unique Hits: $uniqueb<br /> Hits Today: $tdayhitsb<br /> Unique Hits Today: $tdayub "); ?> this is just a straight copy from another site i made which it works completely fine for, well atleast the total hits and hits today works, but using it on new site i just get total hits but its actually displaying a weird total amount of unique hits as once the viewer views it on one day, it then adds to the total hits, and can't be added again until the next day, if that makes sense. This is not my code btw so i don't fully inderstand php yet. So am i doing something wrong? Quote Link to comment https://forums.phpfreaks.com/topic/60640-help-with-a-php-counter/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.