Welcome Guest ( Log In | Register )



4 Pages V  « < 2 3 4  
Reply to this topicStart new topic
> Make Your Own Very Simple Counter Using PHP!
XIII
post Apr 9 2006, 12:16 AM
Post #31


Advanced Member
Group Icon

Group: Members
Posts: 190
Joined: 16-February 06
From: Egypt
Member No.: 11,326



This will not insert any data into the database, it will always say 0 Hits

WOW, i found a solution:

CODE
$conn = mysql_connect("localhost","db_username","db_password") or die('MySQL said:  ' . mysql_error());
$db = mysql_select_db("db_name");
$sql = mysql_query("SELECT * FROM counter") or die('MySQL said:  ' . mysql_error());
while($visits = mysql_fetch_array($sql))
{
$visits = $visits['visits'];
$visits_new = $visits + 1;
}

$query = "UPDATE counter SET visits = '$visits_new'";
mysql_query($query, $conn) or die(mysql_error());

echo "$visits_new Visits";


i removed TABLE from:
$query = "UPDATE TABLE counter SET visits = '$visits_new'";
and don't forget to set the visits value in the database to zero or any number you want, just don't leave it as default.
Go to the top of the page
 
+Quote Post
warallthetm
post Jul 9 2006, 05:33 PM
Post #32


Newbie [ Level 2 ]
Group Icon

Group: Members
Posts: 27
Joined: 9-July 06
Member No.: 14,399



Dose this script count page loads or unique ips? I have been searching fo a php script that count's unique visitors and not just page loads. Is there a way to mod this?
Go to the top of the page
 
+Quote Post
livingston
post Mar 21 2007, 07:27 PM
Post #33


Advanced Member
Group Icon

Group: Members
Posts: 149
Joined: 14-February 07
From: Tuticorin, India
Member No.: 20,415
myCENTs:0.55



wow a great simple and effective counter.
Go to the top of the page
 
+Quote Post
optiplex
post May 4 2007, 09:38 PM
Post #34


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 4
Joined: 4-May 07
Member No.: 21,796



verry good & no mysql !
Go to the top of the page
 
+Quote Post
comkidwizzer3
post Feb 16 2008, 02:37 AM
Post #35


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 6
Joined: 15-February 08
Member No.: 28,436



QUOTE(qwijibow @ Sep 30 2004, 02:23 AM) *
Good... but you might find others steal your counter if they find it...
they will link to your counter script, and store their page cound on your server.

its always good to add some kind of proetection againsed this. a good, but not perfect way is to make sure the referer comes from your own site, and nobody elses.



QUOTE(qwijibow @ Oct 1 2004, 01:56 AM) *
you misunder stand my meaning.......

i mean someone could replace

CODE
<p>Number of guests visiting my site: <? include('alle.txt'); ?>.</p>


the include file with a coomplete URL to anouther server. and replace "alle.txt" with a different filename.


A solution to your problem just encode your webpage.
Go to the top of the page
 
+Quote Post
rockarolla
post Feb 17 2008, 05:00 PM
Post #36


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 48
Joined: 5-February 08
From: Japan
Member No.: 28,155



file based counter may jam - sometimes it wont be able to overwirte the data - when many visitors navigate to your web.

The other problem is if you ain't got permissions to open a file on your server...hence host dependent.

Go to the top of the page
 
+Quote Post

4 Pages V  « < 2 3 4
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics


 



- Lo-Fi Version Time is now: 22nd November 2008 - 10:16 PM