Hit Counter
i am a noob at php and was wondering if anybody could write a hit counter script for me. im not sure if it should be php or javascript, so could someone please write a script for me; it only must count the number of page veiws, nothing special like IP addys or how many in 1 hour.
View Complete Forum Thread with Replies
Related Forum Messages:
Hit Counter Help
I just created a counter in PHP, and was wondering how I would be able to make other websites (which are located on different servers) of mine be able use the same statisitcs/counter. If you don't get my drift, I am almost trying to accomplish a remotely hosting counter service. Counter Info There are two files: counter.php, counterlog.txt If a visitor comes, it opens up the counterlog.txt and it increments. I put an include statement where I want the counter to show. Can you guys help me by answering these questions: 1. What language would I use? 2. Would I call it with JavaScript's script src? If you want, you could also be so kind to write me the script (or at least some of it)
View Replies !
Counter
:) I am following a tutorial for php (hudzilla.org) absolutely loving it however I am having trouble with the counter example <?php // your content here... $filename = 'counter.txt' // our counter file $fp = fopen( $filename,"r"); // open it for READING ("r") $counter = fread($fp, filesize($filename) ); // read in value fclose( $fp ); // close it whilst we work ++$counter; // increase the counter by one print "$counter hits to this page"; // print out the new value $fp = fopen( $filename,"w"); // open it for WRITING ("w") fwrite( $fp, $counter); // write in the new value fclose( $fp ); // close it ?> however it dont werk : by dont work I mean... it wont add to a number held in counter.txt it _will_ read that number fine, just not change it I am currently using # php -v PHP 4.3.10 (cli) (built: Apr 4 2005 04:47:06) Copyright (c) 1997-2004 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
View Replies !
Counter.
I would like to have a counter on my website. I did try a simple code found on the net called "dark Counter" but when the code was placed in my siteheader.php it counted a visitor everytime they clicked a link when in reality it was only one visitor.
View Replies !
PHP Hit Counter
I want to make a simple-as-hell hit counter in PHP that just increments a value in a text file every time the page is loaded, so it would open the file, do a counter++ or something then close the file, then that file can be included in the front page with formatting around it etc.. No referers or any of that stuff is needed.
View Replies !
PHP Counter
Like at the top of each board it says there is so many guests online. Well how do you work out how many people are on one page at a time.
View Replies !
Hit Counter With Url?
I'm trying to make a hit counter that I can then use to show the most popular urls on a site. I've got the simple code from the phpfreaks tutorials section, could anyone give me pointers as to whether it's possible to extend so it somehow tallys based on url? I'm guessing it'd need some way to extract the current url, send to sql table, check if it already exists, if so, add one to that row, if not add a new row.. session_start(); include 'includes/dbconnect.inc.php'; if (!session_is_registered("counted")){ mysql_query("UPDATE simplecount SET count=(count + 1) WHERE count_id=1"); session_register("counted"); }
View Replies !
Making Counter With Php
I am trying to make a counter that counts how many times a certain page has been viewed. First way of doing it that I can think of is creating a file that record the counter. The only thing is that the file will have to have 766 (or 666) permission. Now, my question is: is that safe? I am pretty new to php, but I am worry about giving permission other than 744 or 755. The other idea that I came up with is to store it in mysql. Is it a little too much to store only an integer (unsigned) in a database? I feel like trying to care a glass of water with a big 5-gallon container... Any other suggestion on how to do it will be great too.
View Replies !
IP Logging Counter
Hi. I wrote a script that logs IP's into MySQL and then prints them onto the page. The main purpose of this was a hit counter based on IP addresses. Everytime a user presses refresh or goes to another page, the hit counter adds one and records the IP address again. Here is my code:
View Replies !
Page Counter
It may seem incredibly dumb, but I'm trying to serve a counter for a website that doesn't have PHP. There's probably a very easy way to do it, but so far I've had the following: In the HTML only site an img tag pointing to counter.php as the source. Then the php returns a 1px by 1px image and performs the count and stors teh result in a db. Unfortunately for some reason the count is never updated until the page is refreshed. In other words when you visit the page the image part works fine, but the count isn't. So click the refresh button in the browser and the count goes up by one.
View Replies !
Counter Problem
I got a script that does a multi-query and echos the data. However i wanted to customize how the data is extracted and displayed. So i added in some code to create a table extract the data start the counter after the 10th record the the table is column is closed and next record is displayed on the next column. The multi-query works fine i tested it but the customization fails. I keep getting either errors or not being able to get it to swich to the next column after the 10th record. Heres the code:
View Replies !
Download Counter Help
I have written a php scipt to take a download path given a keyword from an MySQL database, incriment the counter by one, and then set the header to be the download URL. Everything is working well except that the counter is incrimenting by 2 each time. This problem wont happen if the header("Location....") is comented out, and it will behave like a good counter, but, ofcorse, not start the download. I have tried setting the location to be a call to another script, which istelf contains the: if ($download_path) { header("Location: $download_path"); exit; } but the problem still persists if it starts the download... Anyone have a clue what the problem could be?
View Replies !
PHP Counter For Free
I want to create a counter for free to my users, so that anybody could generate a small piece of code and add it to his website and by this way they run their own counters for free.Is there a simple way or a ready made php script that could do this. If anybody could tell me how to do it or the steps will be really...
View Replies !
Downloading Counter
I just wanted to ask if it is possible to have a download counter wherein the counter adds 1 whenever theres is a successful download, not when the user click on the download button?
View Replies !
Download Counter?
I'm trying to create a download counter for individual files on a web site and I'm not sure how to do this. Right now I'm using Webalizer to just read the log files and see how many times the files I'm interested in were downloaded. The problem is Webalizer breaks it up by month and I want a running total. I'd also like to see the counts without having to log in to Webalizer in the first place. Not that logging in or adding the results is too difficult, but it would be nice if I could just put a little number on the web site so when I go to the site I can imediately see the download counts. The first thing I thought of was accessing the log files via PHP and reading the data out of there. However because the log files get broken up, zipped, and a new one started after they reach a certain size I'm afraid this will be too complicated and may put too much extra strain on the server if this is done too often. Also, what's the best way to read log files with PHP anyway?
View Replies !
Advanced Php Counter
I am looking for a advanced php counter. I mean not to increase when I hit 'Refresh' button of the browser and NOT to use SQL database. All the PHP counters I found on the web use a text file that is modified (open, and increase value of the content) when the 'index.htm' is requested by browser (and of course if I request twice from the same browser, same machine it will increase).
View Replies !
Caching IP For Hit Counter?
what's the easiest way to cache an IP for use in a page hit counter, so that if the viewer clicks 'refresh' the counter won't increase; ie it'll only increase when unique viewers access it.
View Replies !
Simple Counter
After a process opened, read and unlocked the counter.txt, some other process would open, read and even write its own count value. So the first process will write a count value less than the right value. And I guess it needs more exception handling codes. Code:
View Replies !
Malfunctioning Counter
I have a field in my database that stores the number of times a particular row has been accessed through a certain page in variable $counter (INT). When a the page is opened, a query is made based on a previous screen's selection (which displays the requested data). I also have a very simple snippet to run the counter, but it won't count over the number one (default field value is zero (0). The code is exceedingly simple, but I don't understand why it isn't working properly: Code:
View Replies !
Counter Script
I added a counter script I downloaded from here , followed the instructions, and it just doesn't appear. Script is supposed to show up under the contact info, and this is the code I added to my own XHTML: PHP Code:
View Replies !
~ Help - Counter Script ~
Here is the scenerio ...is it possibly to do this... i am getting valid course dates output on to a web which i have designed ....all is okay so far , look at the following web url but each of the courses held have maximum of 8 people that could be booked , and i want to put a counter on this so that when the course name,date,time is displayed i want this counter to appear besides each course name so that i can keep track of booking places...all the various course names are held in one table... 2. and if the booking counter is less than 8, i want to have a another button besides the booking counter to say 'add me', which will popup a booking form which the user fills and emails to the course organiser... 3. if the booking counter is less than 3 then the course is not held...pops up message to user... 4. if it is >8 then i want to popup message to say the courses are full booked... can the above be done...if so please supply code snippets starter
View Replies !
PHP Counter MYSQL
im trying to update the amount of hits to a page in a MYSQL database, i have used a session so the hit is not counted twice, but i cannot seem to work out how to add in this variable '$id' to the end of the query 'WHERE id =' as all of the text is in quotes, i do not know how to add the variable in. PHP Code:
View Replies !
PHP Auto Counter
I want to be able to make a list of number in a colum that changes when a line is added to the middle of it. I have looked for it but cant find anything about it. I will put an axample to explain myself better. # | | | | | ------------------ 1 | a | a | a | a | 2 | h | h | h | h | 3 | n | n | n | n | 4 | z | z | z | z | Now i want to add a c value between a and h # | | | | | ------------------ 1 | a | a | a | a | 2 | h | h | h | h | <---------- 3 | c | c | c | c | I want it to get number 3 automatically and that the rest of the numbers rols one forward. 3 | n | n | n | n | 4 | z | z | z | z |
View Replies !
Webpage Hit Counter
Where would I find a website hit counter written preferably in PHP? I do not have shell access to the web provider so installation would have to be via FTP only (no make or compilation)....
View Replies !
Small Counter
I want to make a simple real time counter to show me online visitors. Now the trick is I want it to track the visitors on chat.php page and show them on index.php.
View Replies !
Hit Counter For A Particular Referral?
How would I go about having a hit counter for a particular referral? Lets say I have a banner ad and I want to find out the amount of clicks it's getting. I want it to be something like mysite.com/ref.php?abc and then redirect to index.php. How would that work?
View Replies !
Hit Counter For Links
My first project that i want to make is a hit counter...... For links.. But i saw this tutorial http://www.phpfreaks.com/tutorials/6/0.php And use MySQL database, i dont want to use it.. How can i do for no use mysql
View Replies !
Log Out And Set Online Counter To 0
I have a membership site that I created and as one of the last things I wanted to do was to set when members are online or not. So I know there was probably an easier method but what I did was add a online field to the member table. When a sucessful login is made they go to a loggedin.php page and on that page I have the following code: $query = "UPDATE mwcplayers SET online=1 WHERE id= '".$_SESSION['id']."'"; This works great the users online status is set to 1. My problem is when they log out and getting that online status set to 0 again: here is my logout page logout.php: Code:
View Replies !
Time Counter
Can anyone teach me how to do the time counter? Situation : user enter the number of days he want, php code will save the number into database and from it, the number will decrease each day until it finally reach the time set by the user?
View Replies !
Updating Counter
I need to update a counter when a file is downloaded. The purpose is to know when all the files have been downloaded and then delete the directory. The program lists the files to be downloaded and each download link goes to the start of the program to retrieve the file. My problem is that my counter is not updating. Code:
View Replies !
Site Counter
Is it possible to determin how a user got to your site. At present i have links on serveral web projects that i have worked on. If a user clicks on the link it is then saved to my db upon visit to the site. I would like to be able to find out if they came via a search engine or from a site that does not have my referel id on it. Is this possible with php? I think it might be possible with using the I.E page history but have no idea how to implement it.
View Replies !
Counter And Post
if i have a form to upload files and the boxes are named like: image1, images etc to 5. can i use this when its posted: $image . $counter = $_POST['image' . $counter];
View Replies !
Trying To Make Counter
i want to write a hit counter script. i record the visitor's IP in a temp DB. but when a user leaves my site, i want to delete this IP from DB. how can i get notified that visitor leave it. that is, i want to run a script on body unload.
View Replies !
Effective Hit Counter
I have a massive DB with hundreds of thousands of hits logged for separate pages. If I do a PHP loop to list out all the pages, it loads quickly. If I do any of the queries they take a fraction of a second. If I combine the two to make a page with the information, the load time is insane to say the least. Does anyone know a good way to make a hit counter?
View Replies !
Php Counter Problem
Whenever I access the php counter of my site I get some nasty errors, as below: Warning: fopen(/home/romaniap/domains/.../public_html/phpmycounter/counter.dat) [function.fopen]: failed to open stream: Permission denied in /.../public_html/phpmycounter/counter.php on line 24 Warning: fputs(): supplied argument is not a valid stream resource in /.../public_html/phpmycounter/counter.php on line 25 Warning: fclose(): supplied argument is not a valid stream resource in /.../public_html/phpmycounter/counter.php on line 26 Now, this happens even after I set permission to 755 for all the files in the counter's folder and also for the folder. Code:
View Replies !
Word Counter
I am trying to find out if there is a way to create a function that allows someone to upload a document (.doc, .pdf, .rtf....) and that the system can then count the number of words and give the result to the user. I have intermediate experience of php but I am struggling to find any information about such a function. It may be that it is not possible in php but I would like to know what it is possible in, maybe java?
View Replies !
Developped A Web Counter
I have developped a web counter that displays visitors by country. I would like to be able to offer it to other users/bloggers. I am thinking about a single line that would 'call' my script (let's name it counter.php) and execute it locally. I would obviously have to pass a variable identifying the user.
View Replies !
Incremental Counter
I have created a recursive function that outputs a select menu with nesting inside forced by whitespace to display a nested category list. The designer wants to use alternating row colors on the output but my usual methods are failing due to the recursion. how can i keep a consistent count throughout?
View Replies !
Unique Counter
I've searched google and hotscripts for a unique counter using the GD Library and PHP, but I've not found one I really like. If anyone knows a good script or tutorial on how to create one, please post the link.
View Replies !
Visitors Counter
I need to add a counter for my site visitors that displays their corresponding countris. What method could be implemented to do this ?
View Replies !
File Counter
is there a way i can count the number of files in a server side directory using php? i'm not sure if this sort of thing is possible at all (i'm new to php) but would appreciate any tips or scripts anyone could point me to.
View Replies !
Hit Counter Script
i need to write a hit counter script, which inserts visitors IP address in a database. Delete the IP from DB on users leaving site.
View Replies !
GD Image Counter
i made a very basic hit counter, it works fine, untill i try to print the count on an image and send it to the use Code: <?php $datalog = explode(",",file_get_contents("mi_datalog.txt")); $views = $datalog[0]+1; $last_act = time()-$datalog[1]; if($last_act>=86400)$last_act = round(($last_act-($last_act%86400))/86400)." days"; elseif($last_act>=3600)$last_act = round(($last_act-($last_act%3600))/3600)." hours"; elseif($last_act>=60)$last_act = round(($last_act-($last_act%60))/60)." minutes"; else $last_act .= " seconds"; $my_time = date("h:i:s a"); $nst = date("h:i:s a",time()-68400); $my_np = "11,942"; $fp = fopen("mi_datalog.txt","w"); fwrite($fp,$views.",".$datalog[1]); fclose($fp); $im = ...........
View Replies !
Click Counter
I have been looking everywhere to make a click counter for my site, that uses PHP & MySQL. If you look here you'll see what i'm trying to do. Its all TXT file ran but I want it to use MySQL. Where it looks for data in the MySQL database per link. EG - [ Image with URL - Data Added - Hits - Description ]
View Replies !
Validation Counter
From my code am i able to make a validation counter, then check it against total attemped file uploads? If they arent equal, then i got some stuff ready for it?
View Replies !
Very Simple Counter
I have this code: <?php $fp=fopen("count.txt", "w"); fread($fp, $count194); $count194++; fwrite($fp, $count194); echo $count194; ?> Which is meant to count + 1 every time the page is accessed. As I said, simple. At the moment, I don't want to know if there's a better way to do it. I just want to know why this goes wrong. The count starts at 0, and goes up to 1, but then doesn't go any higher, even with cache-less refreshes.
View Replies !
Counter To An XML File
I have a PHP counter on my website and it writes the count to a text file as it incraments, but it also writes the visiting person's IP to another text file. I want to be able to write the IP's to an XML file, anyone know how I could edit my script to do that? Code:
View Replies !
|