HighDots Forums  

PHP counter (cookies?)

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss PHP counter (cookies?) in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
rG]Courage-D-
 
Posts: n/a

Default PHP counter (cookies?) - 07-04-2004 , 11:47 AM






Hi, this is what i have now: (php mqsql)

$query_string = sprintf("UPDATE Databasetabel SET 2counter = 2counter + 1
WHERE 2name = $name");

And now i want to make the script so, that it will only counts uniq visitors,
can someone help me with this script? (maybe i need cookies?)

thanks


Reply With Quote
  #2  
Old   
Michael Fesser
 
Posts: n/a

Default Re: PHP counter (cookies?) - 07-04-2004 , 12:20 PM






.oO(rG]Courage-D-)

Quote:
Hi, this is what i have now: (php mqsql)

$query_string = sprintf("UPDATE Databasetabel SET 2counter = 2counter + 1
WHERE 2name = $name");

And now i want to make the script so, that it will only counts uniq visitors,
The only way to do this is to have a user login. There's no other
reliable way to identify a user. HTTP is a stateless protocol, each
request could be from a different user, even if it's the same user agent
and IP-address.

Some logfile analyzers interpret the raw logfiles and try to guess how
many unique visitors have been there, but in the end it's only a guess,
not more.

Quote:
can someone help me with this script? (maybe i need cookies?)
And what if the user rejects the cookie or simply deletes it?

Micha


Reply With Quote
  #3  
Old   
rG]Courage-D-
 
Posts: n/a

Default Re: PHP counter (cookies?) - 07-04-2004 , 01:37 PM



thats no problem, i just want it based on a cookie. like this script:
http://www.devscripts.com/visit.php?sId=3220

but i dont know how to put it in my site (that line i gave you must chance,
but i dont know how)


Reply With Quote
  #4  
Old   
rG]Courage-D-
 
Posts: n/a

Default Re: PHP counter (cookies?) - 07-04-2004 , 02:13 PM



someone? it realy dosnt matter if the counter isnt that good, with cookies is OK.

Reply With Quote
  #5  
Old   
Michael Fesser
 
Posts: n/a

Default Re: PHP counter (cookies?) - 07-04-2004 , 04:12 PM



.oO(rG]Courage-D-)

Quote:
thats no problem, i just want it based on a cookie. like this script:
http://www.devscripts.com/visit.php?sId=3220
*rofl*

Quote:
but i dont know how to put it in my site
You don't want to use that script, it's a single big bug.

Quote:
(that line i gave you must chance,
but i dont know how)
OK, try this:

<?php
if (!isset($_COOKIE['hit'])) {
setcookie('hit');
$query_string = "UPDATE Databasetabel SET 2counter = ..."
...
}
?>

First it checks if there's already a cookie 'hit' set for the current
site. If not it sets one (without a value, doesn't matter) and updates
the database.

HTH
Micha


Reply With Quote
  #6  
Old   
rG]Courage-D-
 
Posts: n/a

Default Re: PHP counter (cookies?) - 07-05-2004 , 02:34 AM



thanks, that is working
to bad it isnt working for internet explorer :S

$name = GetSQLValueString($_GET['Animation'], "text");
if (!isset($_COOKIE[$name])) {
setcookie ($name);
$query_string = sprintf("UPDATE Databasetabel SET 2counter = 2counter + 1
WHERE 2name = $name");
$result = mysql_query($query_string, $MYSQL) or die(mysql_error());
}


Reply With Quote
  #7  
Old   
rG]Courage-D-
 
Posts: n/a

Default Re: PHP counter (cookies?) - 07-05-2004 , 03:02 AM



someone knows why that script isnt working in internet explorer? it is working
in opera, maybe i forget something?

$name = GetSQLValueString($_GET['Animation'], "text");
if (!isset($_COOKIE[$name])) {
setcookie ($name);
$query_string = sprintf("UPDATE Databasetabel SET 2counter = 2counter + 1
WHERE 2name = $name");
$result = mysql_query($query_string, $MYSQL) or die(mysql_error());
}


Reply With Quote
  #8  
Old   
Michael Fesser
 
Posts: n/a

Default Re: PHP counter (cookies?) - 07-05-2004 , 03:13 AM



.oO(rG]Courage-D-)

Quote:
thanks, that is working
to bad it isnt working for internet explorer :S
Huh? What version? The following code seems to work in my IE 5/Win2k:

<?php
if (!isset($_COOKIE['hit'])) {
setcookie('hit');
print 'no cookie found';
} else {
print 'cookie found';
}
?>

What version of PHP are you using? What server? What OS?

Micha


Reply With Quote
  #9  
Old   
rG]Courage-D-
 
Posts: n/a

Default Re: PHP counter (cookies?) - 07-05-2004 , 04:17 AM



humm, could you go to this site:
http://ajantis.compactvision.net/public_html/Koen/public_html/Gallery.php

then press the image (there is no image, but you still can press it) Gangster01
then refresh that site
go back to
http://ajantis.compactvision.net/public_html/Koen/public_html/Gallery.php
refresh that site
and see if the counter from 0 has chanced to 2 or to 1

offtopic:
"The download counters have been reset to zero"
is that line good english? (im from holand so i dont know


Reply With Quote
  #10  
Old   
Michael Fesser
 
Posts: n/a

Default Re: PHP counter (cookies?) - 07-05-2004 , 10:56 AM



.oO(rG]Courage-D-)

Quote:
humm, could you go to this site:
http://ajantis.compactvision.net/public_html/Koen/public_html/Gallery.php
[...]
and see if the counter from 0 has chanced to 2 or to 1
Works as expected in IE 5, Mozilla 1.5, Opera 7.22 (all Win2k) and Lynx.
It's the same in all browsers: If I reject the cookie, the counter
increases everytime, if I accept the cookie it increases only once.

I'll test it with IE 6 on Win98 later.

Micha


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.