The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Site Management
> Scripts
|
recording number of clicks
Discuss recording number of clicks in the Scripts forum on Dev Shed. recording number of clicks Scripts forum discussing topics including building, optimization, and implementation. Discuss which scripting language is best suited to your needs.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

August 31st, 2003, 05:39 PM
|
|
Junior Member
|
|
Join Date: Aug 2003
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
recording number of clicks
I would like to record how many times peopple click this one link i have on my website is there a php script that does that or some sort of cgi script? 
|

August 31st, 2003, 07:34 PM
|
 |
Moderator Emeritus
|
|
Join Date: Feb 2002
Location: Scottsdale, AZ
|
|
|
Moved from PHP forum to Scripts forum
|

August 31st, 2003, 07:34 PM
|
 |
Moderator Emeritus
|
|
Join Date: Feb 2002
Location: Scottsdale, AZ
|
|
|
Did you check Hotscripts, Sourceforge, Google... ?
|

September 1st, 2003, 12:48 PM
|
|
Contributing User
|
|
Join Date: Sep 2003
Location: London, England
Posts: 279
Time spent in forums: 11 h 17 m 28 sec
Reputation Power: 10
|
|
|
Re: recording number of clicks
Quote: Originally posted by amorpheus
I would like to record how many times peopple click this one link i have on my website is there a php script that does that or some sort of cgi script? |
Do you still need help?
If it's just one link, you could change it to redirect to (for instance) 'hit.php'.
You would need to have a 'hits.txt' file with 666 access (CHMOD 666 hits.txt)
hit.php:
Code:
<?php
## Open hits counter to get current count ##
$fH = @fopen('hits.txt', 'r');
## Only save new count if it opened ##
if ($fH)
{
$count = fgets($fH, 1024);
@fclose($fH);
## Add one to count (or restart if corrupt) ##
if (is_numeric($count))
$count++;
else
$count = 1;
## Only save if possible ##
$fH = @fopen('hits.txt', 'w');
if ($fH)
fputs($count . "\n");
@fclose($fH);
}
## Redirect ##
header('Location: http://new/url/');
?>
Of course, if you're talking about many links, I'd suggest using a database back-end.
Hope this helps
|

September 1st, 2003, 01:20 PM
|
|
Junior Member
|
|
Join Date: Aug 2003
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
hmm thanx...what does the txt file suposed to look like?
 i tested the link out but it doesnt record it to txt...and im running my own apache webserver on windows so..chmod i dont think is available so how do i deal with that?
|

September 1st, 2003, 03:19 PM
|
|
Contributing User
|
|
Join Date: Sep 2003
Location: London, England
Posts: 279
Time spent in forums: 11 h 17 m 28 sec
Reputation Power: 10
|
|
|
As far as I know, you shouldn't have any problems with write properties on windows.
The text file should create itself. If not, try creating a blank hits.txt (or whatever).
It's possible Apache isn't letting you create new files.
If you take the '@' symbols off while debugging, it should give you some extra info.
|

September 1st, 2003, 06:54 PM
|
|
Junior Member
|
|
Join Date: Aug 2003
Posts: 7
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
it doesnt log anything to hit.txt....
|

September 2nd, 2003, 02:15 AM
|
|
Contributing User
|
|
Join Date: Sep 2003
Location: London, England
Posts: 279
Time spent in forums: 11 h 17 m 28 sec
Reputation Power: 10
|
|
|
Have you tried removing the '@' symbols to see if any errors are produced?
It should tell you if the file cannot be read or written to, for any reason.
|

September 5th, 2003, 03:39 PM
|
|
Banned
|
|
Join Date: Sep 2003
Location: Chandigarh, India
Posts: 33
Time spent in forums: 17 sec
Reputation Power: 0
|
|
|
Lot of click tracking scrupts out there !!at hotscripts !!
|

November 12th, 2003, 08:32 AM
|
|
// banan2 PRIDE //
|
|
Join Date: Oct 2003
Location: Norway
Posts: 303
  
Time spent in forums: 14 h 57 m 46 sec
Reputation Power: 11
|
|
|
Re: Re: recording number of clicks
Quote: Originally posted by Wite_Noiz
Do you still need help?
If it's just one link, you could change it to redirect to (for instance) 'hit.php'.
You would need to have a 'hits.txt' file with 666 access (CHMOD 666 hits.txt)
hit.php:
Code:
<?php
## Open hits counter to get current count ##
$fH = @fopen('hits.txt', 'r');
## Only save new count if it opened ##
if ($fH)
{
$count = fgets($fH, 1024);
@fclose($fH);
## Add one to count (or restart if corrupt) ##
if (is_numeric($count))
$count++;
else
$count = 1;
## Only save if possible ##
$fH = @fopen('hits.txt', 'w');
if ($fH)
fputs($count . "\n");
@fclose($fH);
}
## Redirect ##
header('Location: http://new/url/');
?>
Of course, if you're talking about many links, I'd suggest using a database back-end.
Hope this helps |
Didnt work..
Error:
Warning: Wrong parameter count for fputs() in /mnt/home3/b/ba/banan289/public_html/m-eye/gbcount.php on line 20
Warning: Cannot add header information - headers already sent by (output started at /mnt/home3/b/ba/banan289/public_html/m-eye/gbcount.php:20) in /mnt/home3/b/ba/banan289/public_html/m-eye/gbcount.php on line 25
__________________
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|