Be a Supporter!

PHP: Counting unique hits

  • 1,400 Views
  • 20 Replies
New Topic Respond to this Topic
Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
PHP: Counting unique hits Apr. 17th, 2006 @ 06:56 AM Reply

For the tut, see here: http://www.thesmurk...?page=vtut&id=47

Sorry about having to link.

citricsquid
citricsquid
  • Member since: Jun. 25, 2005
  • Offline.
Forum Stats
Member
Level 23
Blank Slate
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 07:08 AM Reply

Thankyou thankyou thankyou thankyou <3

I have been looking for a good tutorial on this <3 this will really help me, thankyou so much, and good tutorial.

Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 07:15 AM Reply

That's ok. I was looking for one like this for ages, which is I learnt PHP, and wrote it.

:-D

Pilot-Doofy
Pilot-Doofy
  • Member since: Sep. 13, 2003
  • Offline.
Forum Stats
Member
Level 37
Musician
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 11:11 AM Reply

lol This cat asked me for help on this tutorial making process. Anyway, why would you use a database for such small things like this? A txt file would really be all you need.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 12:16 PM Reply

At 4/17/06 11:11 AM, Pilot-Doofy wrote: lol This cat asked me for help on this tutorial making process. Anyway, why would you use a database for such small things like this? A txt file would really be all you need.

However you are right, I am saving it the DB as well.

But my script is ALOT smaller, and, because of it, faster.

Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 12:26 PM Reply

At 4/17/06 11:11 AM, Pilot-Doofy wrote: lol This cat asked me for help on this tutorial making process. Anyway, why would you use a database for such small things like this? A txt file would really be all you need.

Well, mostly because I wanted to practice my SQl.

:D

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 12:32 PM Reply

At 4/17/06 12:26 PM, Rellizate wrote:
At 4/17/06 11:11 AM, Pilot-Doofy wrote: lol This cat asked me for help on this tutorial making process. Anyway, why would you use a database for such small things like this? A txt file would really be all you need.
Well, mostly because I wanted to practice my SQl.

D

You want me post mine version? If you want to I'll do it.

Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 12:35 PM Reply

No thanks. I know yours will be better, so there is no point...

xD

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 12:44 PM Reply

At 4/17/06 12:35 PM, Rellizate wrote: No thanks. I know yours will be better, so there is no point...

xD

Ok...but it is like:
1) GET IP
2) Check if the same one already in the db
3) if no, insert it
4) else do nothing (but there's no actually part like else {} )

Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 12:45 PM Reply

That's exactly what mine does.

Zendra
Zendra
  • Member since: Sep. 7, 2003
  • Offline.
Forum Stats
Moderator
Level 51
Blank Slate
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 01:49 PM Reply

At 4/17/06 12:26 PM, Rellizate wrote: Well, mostly because I wanted to practice my SQl.

Better do that in your own time. ;)
You need to give people the best solution which is fast and secure - if you'd ask me.

Ziaja
Ziaja
  • Member since: Oct. 2, 2005
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 07:04 PM Reply

I think this was ment to be an affiliate in/out counter (at least thats what i gather from the comment he left).


Obnoxious2ombie.com - Online Drug Lord!

thoughtpolice
thoughtpolice
  • Member since: Mar. 24, 2003
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to PHP: Counting unique hits Apr. 17th, 2006 @ 08:19 PM Reply

At 4/17/06 12:16 PM, Nino_JoJ wrote: However you are right, I am saving it the DB as well.

But my script is ALOT smaller, and, because of it, faster.

A smaller script doesn't me flat out anything - my entire website is run off of five lines of PHP, but that doesn't mean it's going to work any faster than somethingawful.


omg.
Playstation Network tag: muffin-noodle
the empty set

Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to PHP: Counting unique hits Apr. 18th, 2006 @ 10:54 AM Reply

At 4/17/06 07:04 PM, Ziaja wrote: I think this was ment to be an affiliate in/out counter (at least thats what i gather from the comment he left).

Well, it only counts in. Also this was actually created for seeing how many unique hits, sites which you bought advertising off sent you.
You can use it for lots of stuff, though.

Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to PHP: Counting unique hits Apr. 18th, 2006 @ 11:16 AM Reply

Ok, fixed.

Change line in add_new.php where it says:
$result = mysql_query("select * from supporters limit 1");

to:
$result = mysql_query("SELECT id FROM supporters ORDER BY id DESC LIMIT 1");

netster403
netster403
  • Member since: Jul. 31, 2003
  • Offline.
Forum Stats
Member
Level 09
Blank Slate
Response to PHP: Counting unique hits Apr. 18th, 2006 @ 11:39 AM Reply

sweetness, always looking for php goodies, thank ya kindly :P

Rellizate
Rellizate
  • Member since: Feb. 27, 2006
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to PHP: Counting unique hits Apr. 18th, 2006 @ 02:53 PM Reply

That's ok.

Remember to:

change line in add_new.php where it says:
$result = mysql_query("select * from supporters limit 1");

to:
$result = mysql_query("SELECT id FROM supporters ORDER BY id DESC LIMIT 1");

knugen
knugen
  • Member since: Feb. 7, 2005
  • Offline.
Forum Stats
Moderator
Level 42
Programmer
Response to PHP: Counting unique hits Feb. 16th, 2007 @ 03:26 PM Reply

The link is broken :'(

Mister-Mind
Mister-Mind
  • Member since: Jul. 1, 2006
  • Offline.
Forum Stats
Member
Level 07
Blank Slate
Response to PHP: Counting unique hits Feb. 16th, 2007 @ 03:34 PM Reply

At 2/16/07 03:26 PM, DreamworX wrote: The link is broken :'(

Yuppers,

Im going to pm the thread starter asking if he can make another thread and called php: counting unique hits and he can remake the tut, and replace it in the PHP Main

knugen
knugen
  • Member since: Feb. 7, 2005
  • Offline.
Forum Stats
Moderator
Level 42
Programmer
Response to PHP: Counting unique hits Feb. 16th, 2007 @ 03:36 PM Reply

At 2/16/07 03:34 PM, PHPgeek wrote: Im going to pm the thread starter asking if he can make another thread and called php: counting unique hits and he can remake the tut, and replace it in the PHP Main

Ok, do you think that you could PM me if he does so? Thanks :)

juraj
juraj
  • Member since: May. 15, 2004
  • Offline.
Forum Stats
Member
Level 29
Blank Slate
Response to PHP: Counting unique hits Feb. 16th, 2007 @ 05:11 PM Reply

Counting unique hits isn't so tough to set-up. You just need a MySQL database and an idea what you're trying to accomplish :-)

BTW, what is exactly considered an unique hit? A single request from an IP address in 24 hours?