Jump to content

help with a php counter


addy_010

Recommended Posts

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.