WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
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 Resources
Web Development Content
Internet Security Software
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
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

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 : A Simple hit counter, which also outputs alt tags on images for text browsers. Does not require any library functions or mysql.
Categories : PHP, Complete Programs Update Picture
Steven anonymous
Date : Feb 15th 2000
Grade : 3 of 5 (graded 6 times)
Viewed : 13585
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Steven anonymous
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Note: You will need to find some digits from somehere, name them as 0.gif, 1.gif, 2.gif etc. The
counter logs hits only, there is no support for cookies or host logging in this version. For
updates and images check http://www.iptoolz.com/

To get it to work, simpy modify the code bellow this paragraph where appropriate and upload
to your server. Then on php3 pages which you want the counter to appear, use <? include
("script location"); ?>

<?

///////////////////////////////////////////////////////////////////////////////////
//| A really simple HitCounter, written in PHP3 | Free for non commercial use only
//--------------------------------------------------------------------------------
//| Coded by Steven @ Not Applicable Foundation | Distributed with NO Warranty of
//| (Whilst all normal people were eating lunch, | any kind. Use at your own risk.
//| this header took longer than the code :) | Please do not modify this header.
//---------------------------------------------------------------------------------
//| Made because the one i downloaded and was using before broke after 38,000 hits!
//| Also this one outputs alt tags containing the hit number, so that people whose
//| browsers don't display pictures can see the hit count.
//---------------------------------------------------------------------------------
//| Change this to the location of the file containing hits. File must be readable
//| and writable. Create if necessary, adding a start number (0?).
//|

        $fileloc = "/home/mysite/hits.txt";

//|
//| Change this to the url directory containing the images, including trailing /
//|

        $imagedir = "http://www.mysite.com/images/";

//|
//| If the counter is broken, or there is a problem, it will display nothing unless you set this to 1
//|

        $debug = 0;

//|_________________________________________________________________________
________
////////////////////////////////////////////////////////////////////////////////////


if(is_file($fileloc))
{
        if($hits = file($fileloc) AND $file = fopen($fileloc, "w"))
        {
                $hits = trim($hits[0]) + 1;
                fputs($file, $hits);
                $length = strlen($hits);
                fclose($file);
                $file = fopen($fileloc, "r");
                echo "<table cellspacing=0><tr>\n";
                for($repeat = 1; $repeat <= $length; $repeat++)
                {
                        $number = fgetc($file);
                        echo "<td><img src=\"$imagedir$number.gif\" alt=\"$number\">
\n";
                }
                echo "</tr></table>\n";
                fclose($file);
        }
        else
        {
                if($debug != 0)
                {
                        echo "Error: Could not open the file, or file does not contain a
valid number";
                }
        }
}
else
{
        if($debug != 0)
        {
                echo "Error: Hit file does not exist, or there has been a disk failure";
        }
}

?>



PHP-MySQL shopping cart
Categories : PHP, Ecommerce, Complete Programs
databases administration remote Web
Categories : mSQL, PHP, Complete Programs, Databases
This is a very simple BBS that uses MySQL
Categories : MySQL, Databases, Complete Programs, PHP
DBE - Database Expander: Edit PostgreSQL individual database tables online via your Web browser!
Categories : PostgreSQL, Complete Programs, Databases, PHP Classes, PHP
GroupIT Content Management and Community Engine
Categories : PHP, Complete Programs, Content Management
Expose - PHP template engine, supports server and client-sided caching,a plugin system, multiple languages, template script language is based on PHP itself.
Categories : PHP, PHP Classes, Templates, Complete Programs
Finds files on your site, uses UNIX find command.
Categories : Complete Programs, Filesystem, PHP
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
Create and restore backup of MySQL databases
Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs
phpAds, a complete banner and ad management system with detailled tracking and stats.
Categories : MySQL, Complete Programs, Ecommerce, PHP, Databases
Point and Click Interface ala MS Access for creating SQL statements.
Categories : MySQL, Complete Programs, General SQL, PHP, Databases
Rich Editor (RE) is a cross-browser WYSIWYG html editor
Categories : Content Management, Editors and IDEs, PHP, Complete Programs
Example voting script. Lets people enter suggestions and vote for existing ones.
Categories : MySQL, PHP, Cookies, Complete Programs, Databases
ClassFuncDoc - This script is a classes and functions documentation tool.
Categories : PHP, Classes and Objects, Documentation, PHP Classes, Complete Programs
Free For All Links Page using PHP3 and Mysql
Categories : PHP, MySQL, Complete Programs
 Patrick Mueller wrote : 253
Hi,
i think it`s not necessary to open the counter-file again,
because a few lines before the script already has the value.
This should save some time.
 
 Anonymous Steven wrote :257
yeh you`re absolutely right, if i rewrote it i would use w+ 
and just use fgets, but as i said, i wrote both it and a 
host counter during my lunch hour cause the old one 
died. It works with no problems and the time difference 
isn`t noticable. It`s such a simple script that i would 
hope anyone who downloads it would do it for learning 
as opposed to "i have no clue how to make one myself, 
i think i`ll use this".  When i get my site running i`ll do 
some proper scripts for download.