simple click tracker<

windows

Guest
after searching for ages, i cant seem to find exactly what i want.

everything that turns up wants to dish out fancy reports and whatnot.

all i want is a simple counter that updates whenever someone clicks a certain link.
I tried just using my counter code with a onClick, but... that didnt work.

in case you dont know what im talking about, go to <!-- w --><a class="postlink" href="http://www.morrowasted.com/media.php">www.morrowasted.com/media.php</a><!-- w --> and click the music link.
There is a table with all the files and their attributes. I want to add a "Download s" attribute to show how many times it has been Download ed.

any help:( ?dude! Google "downi tracker" - it's what i use. PAINfully simple. just a counter that tells you how many times someone's clicked on a link. the downside (as is with all link counters) is that you have to make a special link for the outside world and enter the REAL URL in the admin interface.This would be really easy to do with PHP.... however, I tried to go to your site to see what you meant, and the fonts were so small I couldn't read it.

I'm using Mozilla 1.5 BTW.

Adamthat reminds me... i forgot to add that downi requires PHP/MySQL... though i'm sure it can be modified to work on a flat textfile.Originally posted by transmothra
dude! Google "downi tracker" - it's what i use. PAINfully simple. just a counter that tells you how many times someone's clicked on a link. the downside (as is with all link counters) is that you have to make a special link for the outside world and enter the REAL URL in the admin interface.

i think i just Download ed that, all the sites were in german;)

im not sure if i understand what you mean, but lemme see for myself.
that reminds me... i forgot to add that downi requires PHP/MySQL... though i'm sure it can be modified to work on a flat textfile.

i've got MySQL here. for some reason, its not connecting... wait oops i forgot to... duh

Passwort eingeben:?

i guess that means password...
okay, "data were inserted", i guess thats good.

seems easy enough, lets see if i can get this sucker workin!

hmmm... "Connection Error" whenever i click the link...

ive got <?php number("01"); ?>
<a href=http://www.htmlforums.com/archive/index.php/"tracker/downi.php?id=01">Zelda- Hyrule</a>

eh... thats right, right? looking at the code, looks like its probably a link error, but i know its not...

arg, still a connection error!

check it at <!-- m --><a class="postlink" href="http://24.238.145.39/flash/version7/media2.phpmake">http://24.238.145.39/flash/version7/media2.phpmake</a><!-- m --> sure you entered in your database info. i think it goes in the function.php file or something.it is easy.

all you do is have your link go to a track.php page that records the link in mysql and then sends you on your way.

so each link looks like so

track.php?id=2&url=http://site.com

or something similiar, so now it goes to track.php and adds a 1 to the database where id=2 sits.

very easy Greg and a good one to practice on. then to see how the links look as far as seeing the count, just query the database and look at them.thanks scoutt.

i think for now im just going to use flat file and other "alternative", but as soon as i get some time i guess i can write out that script.

this is the script that i got
require("function.php");
$result = mysql_query("select hits,link from tracker where id = '$id'");
$hits = mysql_result($result,0,"hits");
$link = mysql_result($result,0,"link");
mysql_query("update tracker set hits=hits+1 where id='$id'");
if ($link=='') {
echo "Connection Error";
exit;
}
header("Location: $link");
?>

i dont see how that would work... it never establishes the connection to begin with. oh, ok, it connnects here:


$hostname = "localhost";
$username = "morrowasted";
$passwort = "**********";
$dbName = "Download ";

$verbindung = @MYSQL_PCONNECT($hostname, $username, $passwort) OR DIE("No connection!");
@mysql_select_db("$dbName") or die( "The database could not be selected");

function number($id) {
$result = mysql_query("select hits from tracker where id = '$id'");
$hits = mysql_result($result,0,"hits");
echo $hits;
}

?>

theres also an sql file here:confused:
i can insert data succesfully, but i just cant connect to the dern db every time i click the link!instead fo pconnect, try just connect.

$verbindung = @mysql_connect($hostname, $username, $passwort) OR DIE("No connection!");still a connection error...

ill just have to use my alternative for now:(

on second, thought, my alternative doesnt work either.

maybe ill just scrap the Download counter:rolleyes:i know this is probably way off, but could the problem have to do with the double slash?
( the url is <!-- m --><a class="postlink" href="http://24.238.145.39/flash/version7//media2.php">http://24.238.145.39/flash/version7//media2.php</a><!-- m --> )you haven't run the SQL file yet? you have to do that first to set up the tables you need to insert data into. are you sure your database name is "Download "? check that, too. and for user/pw, often times a webhost have those set up to be different that your regular FTP user/pass. so double-check everything!1- i manually inserted the table data, so its there
2-yes, i made this database specifically for this task
3-its running on my computer, and yes, they are correct;)if you're running that locally, try taking out the password, and then try taking out the password AND username. i don't understand why, but on my MySQL, it just won't work like that, no matter what i try. maybe yours is like that too.oh, i just noticed that on admin_downi.php, toward the top of the page, there is this:<?php
/*
(a bunch of notes and copyright and something about french fries) */

if ($pass=="***PASSWORD***") {
require("function.php");
// connect to database if password is correct
$db = mysql_connect($hostname, $username, $passwort);
mysql_select_db($dbName,$db);
?>so make sure you also put in your password there, too.Originally posted by transmothra
oh, i just noticed that on admin_downi.php, toward the top of the page, there is this:<?php
/*
(a bunch of notes and copyright and something about french fries) */

if ($pass=="***PASSWORD***") {
require("function.php");
// connect to database if password is correct
$db = mysql_connect($hostname, $username, $passwort);
mysql_select_db($dbName,$db);
?>so make sure you also put in your password there, too.

that is the password you use to log in the the administration page, not the database password.

if you're running that locally, try taking out the password, and then try taking out the password AND username. i don't understand why, but on my MySQL, it just won't work like that, no matter what i try. maybe yours is like that too.
if i dont, it wil log me in as root, and i dont think the databases i have created under the username morrowasted will exist under root, but i'll try it

edit:nope:(So the German precision is failing you, eh? ;)
It would really take less time to write this script on your own.. and use PhpMyAdmin as admin area.. really!i don't get it... it's the simplest script ever! why wouldn't it work?! it's not even like it's a register_globals thing, either!i don't get it... it's the simplest script ever! why wouldn't it work?! it's not even like it's a register_globals thing, either!
i know, ive set up phpbb and phpnuke on this machine before, this should be a piece of cake!what error are you getting exactly?well, in the "downi.php" they have it set up so that if it cant connect to the DB, it outputs "Connection Error", and thats what im gettingyou are getting that then you are connecting. I beleive it is here

require("function.php");
$result = mysql_query("select hits,link from tracker where id = '$id'");
$hits = mysql_result($result,0,"hits");
$link = mysql_result($result,0,"link");
mysql_query("update tracker set hits=hits+1 where id='$id'");
if ($link=='') {
echo "Connection Error";
exit;
}
header("Location: $link");
?>

if that is it then you have other problemsOriginally posted by scoutt
you are getting that then you are connecting. I beleive it is here

require("function.php");
$result = mysql_query("select hits,link from tracker where id = '$id'");
$hits = mysql_result($result,0,"hits");
$link = mysql_result($result,0,"link");
mysql_query("update tracker set hits=hits+1 where id='$id'");
if ($link=='') {
echo "Connection Error";
exit;
}
header("Location: $link");
?>

if that is it then you have other problems

ok?

is there some kind of hidden clue there?yeah, I bolded the clue. trace it back and you will see.

if that is the error then you have issues with $link being empty.

$link = mysql_result($result,0,"link");

if that is empty in your database then you will have an error. hence why you can't goto the link. but I am not sure where the error is comnig from because you don't say.

is it when you first start or when you click on a link?see for yourself:

<!-- m --><a class="postlink" href="http://morrowasted.com/media2.php">http://morrowasted.com/media2.php</a><!-- m -->

click the music link, then click the first link from the list that pops up.

you'll get the error.if that is the error then you have issues with $link being empty. so that means that it thinks the link is incorrect, or that theres no info in the database?woah!

i think its working!

i dont know what i did, but i think its actually wokring!@!!!!@fvsdfaswrwa

YES!!! HALLELUJAH!!!

PARTY AT MY PLACE

thanks for the help:cool:cool
 
Back
Top