WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Smart Counter - This little script is a plain and simple hit counter that uses cookies to determine whether or not the visitor has already been counted.
Categories : Cookies, HTML and PHP, PHP Update Picture
Jason Hines
Date : Jul 19th 1999
Grade : 4 of 5 (graded 1 times)
Viewed : 10629
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Jason Hines
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?php
/*
Orig: simple access counter for php3
(c)1998 David W. Bettis
dbettis@eyeintegrated.com

        Modified smart counter:
         Uses cookies to determine whether or not to bump the
         count. Cookie expires after 10 minutes.

        v1.1 Jason Hines <openface@eyeintegrated.com>
*/

$counterFile = "/home/httpd/html/counter/counter.text";

function displayCounter($counterFile) {
global $counted
$fp = fopen($counterFile,rw);
$num = fgets($fp,5);
if (!$counted) {
$num += 1;
unlink("$counterFile");
exec("echo $num > $counterFile");
}
print "$num";
}

if (!file_exists($counterFile)) {
exec("echo 1 > $counterFile");
}

displayCounter($counterFile);
?>


/* Add the following to the very top of the page you want to count */

<?php if (!$counted) { setcookie("counted",1,time()+600); } ?>
PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
Make old style (PHP3) scripts using GET, POST, COOKIE and File uploads (POST) compatible with PHP 4.2.0
Categories : PHP, HTML and PHP, Global Variables, Cookies, Variables
Complete, simple working example of login screen and check on a unique page using php functions, cookies and mysql database.
Categories : PHP, Cookies, MySQL, HTML and PHP, Authentication



PHP alternating the colors of table rows with style.
Categories : PHP, HTML and PHP, CSS
Customizable Calendar Class
Categories : HTML and PHP, Date Time, PHP, PHP Classes, Calendar
Amazon book cover handling
Categories : HTML and PHP, PHP, MySQL, Ecommerce
CSS style switcher
Categories : PHP, CSS, HTML and PHP, Arrays, Sessions
Functions for loading images into a MySQL database and displaying them.
Categories : Graphics, HTML and PHP, MySQL, PHP, Databases
dynamic table columns
Categories : PHP, HTML and PHP, Arrays, Databases, MySQL
Vote-Poll script that has a wrapper class that allows the user to create multiple polls on the same page with little trouble.
Categories : PHP, PHP Classes, HTML and PHP
PHP function which gets all the data from a webpage into a string, we can perform regular expression functions on that data afterwards to get our desired data.
Categories : PHP, URLs, HTML and PHP
GonxTabs : Create elegant HTML tabs based interface
Categories : Navigation, HTML, HTML and PHP, PHP
Real simple example of removing HTML tags from text then changing \n (new line) to <br>. Could be used in a forum for instance.
Categories : HTML, PHP, HTML and PHP, Beginner Guides
Simple script to passing persistent and growing array between recalls of one page (manipulate little stack).
Categories : Arrays, Global Variables, PHP, HTML and PHP, Variables
 Rudi Ahlers wrote : 548
Can someone please help me with this script. I get nerror:         Parse error: parse error, expecting ``,`` or ``;`` in /home/www/projects/header.php on line 21 which is: 
$fp     = fopen($counterFile,rw);
I do have the file counter.txt, as -rw-rw-rw
But it doesn`t seem to read the file, I even included the whole path to the file. Can someone please tell me why?
 
 xtentic xtentic wrote :734
function displayCounter($counterFile) { 
        global  $counted; 
        $fp     = fopen($counterFile,rw); 
        $num    = fgets($fp,5); 
        if (!$counted) { 
                $num    += 1; 
                unlink("$counterFile"); 
                exec("echo $num &gt; $counterFile"); 
        } 
        print "$num"; 



^^^^ This works! 4 real