>I'm trying to build a counter that will keep trach how many hits I got
>and where they came from.
Your webserver already does this for you. Get the raw server logfiles
and use a logfile analyzer like AWStats. Your host might offer something
like that already.