Forum Thread
  Posts  
My counter isnt working O_o (Forums : Coding & Scripting : My counter isnt working O_o) Locked
Thread Options 1 2
Mar 27 2003 Anchor
<? include("config.php");

mysql_query("INSERT INTO unz_hits (host,browser,time,referer,filename) VALUES ('$host', '$browser', '$time','$referer','$PHP_SELF')");
mysql_query("UPDATE unz_stats SET count = count + 1");

?>

Isnt working :/ I have no idea why...everythings set in the config...Heres the config bits...

function datetime()
{return date("Y-m-d H:i");}
$time = datetime();

$ip = getenv("REMOTE_ADDR");

$host = @GetHostByAddr($ip);
$real_host=chop($host);
if($real_host)
{$host_arr=explode(".", $real_host);
$count=count($host_arr);
if($count > 1)
{if(intval($host_arr[$count-1])!=0)
{$host=substr($real_host,0,strrpos($real_host,".")).".*";}
else
{$host = "*".strstr($real_host, ".");}}
else
{$host=$real_host;}}
else
{$host="";}

$browser = $HTTP_USER_AGENT;
$referer = getenv("HTTP_REFERER");
global $dblink,$PHP_SELF;


Dunno why its not working :/

- Edited By azz0r On Thu 27th, Mar 2003 @ 7:51:56pm

--

Why wont it save me?

jacksonj04
jacksonj04 Over 9000
Mar 30 2003 Anchor

um... all looks fine to me. Is it that neither of those tables update or is it just one?

--

Barcode Imagejacksonj04 the generally helpful one
Lost, confused or just need a virtual cuddle? PM me.
Need urgent help from staff? PM us all.

Mar 30 2003 Anchor

Sorted now :) The problem was a simple one; I got the table names the wrong way round, however the count row still isnt working.

--

Why wont it save me?

jacksonj04
jacksonj04 Over 9000
Mar 30 2003 Anchor
mysql_query("UPDATE `unz_hits` SET `count` = `count` + 1");

- Edited By jacksonj04 On Sun 30th, Mar 2003 @ 5:11:55pm

--

Barcode Imagejacksonj04 the generally helpful one
Lost, confused or just need a virtual cuddle? PM me.
Need urgent help from staff? PM us all.

INtense!
INtense! End Boss
Mar 30 2003 Anchor

Working now? and it always does help if you post the error message you get cos then it'll take me like 0.1 seconds to figure out the problem ;)

--

Scott Reismanis
DBolical | @scottreismanis

PsychoFarmer
PsychoFarmer modDB King
Mar 30 2003 Anchor

intense, u so smart!!!

i wanna learn php, but its confusing without knowing anything other than html... i need like a book or somethin O_o

- Edited By PsychoFarmer On Sun 30th, Mar 2003 @ 6:22:44pm

--

___________________________
Today seems like a good day to burn a bridge or two
I am the freakiest man in the world!!!!
I beg to differ, on the contrary, I agree with every word that you say

User Posted Image

Mar 31 2003 Anchor

Theres alot of books :)

Its working now, Im not sure its a good thing though, each time the headers used a row is inserted with host,browser,time,referer,filename...I'd make a cookie but I dunno, I wanna kinda monitor every page visit O_o

--

Why wont it save me?

jacksonj04
jacksonj04 Over 9000
Mar 31 2003 Anchor
error_reporting(E_ALL);

I whack this in at the top of every script, helps write less buggy code.

--

Barcode Imagejacksonj04 the generally helpful one
Lost, confused or just need a virtual cuddle? PM me.
Need urgent help from staff? PM us all.

Mar 31 2003 Anchor

Thnaks, going to test your updated query for the no of hits in a second...

currently purchasing unreal 2 at the moment so my connections slow.

--

Why wont it save me?

Mar 31 2003 Anchor

Nope, still @ 0.

--

Why wont it save me?

jacksonj04
jacksonj04 Over 9000
Mar 31 2003 Anchor

INtense! wrote: Working now? and it always does help if you post the error message you get cos then it'll take me like 0.1 seconds to figure out the problem ;)


I can do that too, for example:

Syntax Error on line 46


This immediately tells me there is a syntax error on line 46.

--

Barcode Imagejacksonj04 the generally helpful one
Lost, confused or just need a virtual cuddle? PM me.
Need urgent help from staff? PM us all.

PsychoFarmer
PsychoFarmer modDB King
Mar 31 2003 Anchor

:o, wow ur good :P

azz0r, how much does unreal 2 cost u to "buy"? ;)

and what would u php mastahs recommend for learning php? prerequisites?

--

___________________________
Today seems like a good day to burn a bridge or two
I am the freakiest man in the world!!!!
I beg to differ, on the contrary, I agree with every word that you say

User Posted Image

jacksonj04
jacksonj04 Over 9000
Mar 31 2003 Anchor

webmonkey, php.net, search for code samples and hack them.

Oh, make sure your server has PHP installed.

Quick starter:

<?php

echo ("Hello World!");

php?>

--

Barcode Imagejacksonj04 the generally helpful one
Lost, confused or just need a virtual cuddle? PM me.
Need urgent help from staff? PM us all.

BigBird
BigBird Mod DB Pilot
Apr 1 2003 Anchor

INtense! wrote: Working now? and it always does help if you post the error message you get cos then it'll take me like 0.1 seconds to figure out the problem ;)


*me knows how the INtense mode of debugging works back to front :D

/me hands INtesnse a six pack of crownies for his trouble last night :beer:

--

BigBird

Mod DB Guy
Play Something Different

Apr 1 2003 Anchor

jacksonj04 wrote: webmonkey, php.net, search for code samples and hack them.

Oh, make sure your server has PHP installed.

Quick starter:

<?php

echo ("Hello World!");

php?>

heh, they have that code on the php.net tutorial...

--

______________________
Nichts ist für dich
Nichts war für dich
Nichts bleibt für dich
Für immer

Apr 2 2003 Anchor

Probably where he copy pasted it from

so

$result['row'] or $result[row] is better?
I use the latter, however I used Jacksons error code and I got lotsa weird messages about my result use O_o

--

Why wont it save me?

jacksonj04
jacksonj04 Over 9000
Apr 2 2003 Anchor

yep. It shows every error, so if you get some your code actually throws up some errors but they're just not printed.

I'd say $result['row'] to be honest.

--

Barcode Imagejacksonj04 the generally helpful one
Lost, confused or just need a virtual cuddle? PM me.
Need urgent help from staff? PM us all.

Apr 2 2003 Anchor

Perhaps I'm missing something here.

Why do you need the unz_stats counter when you're logging each page hit? Why don't you just:

mysql_query("select count(filename) as pageHits from unz_hits where filename = '$PHP_SELF'");

--

Give me ambiguity or give me... something else.

Dominant Species scope.creep User Posted Image

jacksonj04
jacksonj04 Over 9000
Apr 2 2003 Anchor

this is azz0r you're talking about here. He likes long methods.

--

Barcode Imagejacksonj04 the generally helpful one
Lost, confused or just need a virtual cuddle? PM me.
Need urgent help from staff? PM us all.

Apr 2 2003 Anchor

Because I want a seperate counter to :P

Me and Jacko just did some cleaning up and managed to fudge up commenting in the process O_o

--

Why wont it save me?

PsychoFarmer
PsychoFarmer modDB King
Apr 2 2003 Anchor

i think he wanted to see exactly who was visiting his site O_o

--

___________________________
Today seems like a good day to burn a bridge or two
I am the freakiest man in the world!!!!
I beg to differ, on the contrary, I agree with every word that you say

User Posted Image

jacksonj04
jacksonj04 Over 9000
Apr 2 2003 Anchor

all I know is his code was full of errors

--

Barcode Imagejacksonj04 the generally helpful one
Lost, confused or just need a virtual cuddle? PM me.
Need urgent help from staff? PM us all.

PsychoFarmer
PsychoFarmer modDB King
Apr 2 2003 Anchor

its azz0r, what did ya expect :rolleyes:

my code is always full of errors, but thats cuz i usually forget to put everything is quotes :P

--

___________________________
Today seems like a good day to burn a bridge or two
I am the freakiest man in the world!!!!
I beg to differ, on the contrary, I agree with every word that you say

User Posted Image

Apr 2 2003 Anchor

It wasnt full off errors, my style just differed from the strict PHP style :P It still worked; just slower.

--

Why wont it save me?

PsychoFarmer
PsychoFarmer modDB King
Apr 2 2003 Anchor

:rolleyes:

i wonder how many times azz0r will delete this post...

--

___________________________
Today seems like a good day to burn a bridge or two
I am the freakiest man in the world!!!!
I beg to differ, on the contrary, I agree with every word that you say

User Posted Image

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.