Forum Moderators: coopster
BTW, unless you are counting downloads or some such thing, my personal opinion is that counters *usually* look amateurish. You may have your reasons, but you may want to examine them and ask what the counter is really doing for you and your visitors.
-set up PHP (using .htaccess options) to auto_prepend a file to every PHP page that's requested.
- if the site consists of non-php pages, set up the server to treat them all as PHP and, thus, prepend the file you specified in the previous step.
- the prepended file simply checks for the URL which has been requested and uses that as the key for your database. If the URL exists in the DB, the value gets incremented by one. If it doesn't yet exist, a record gets created for that URL and it gets set to a value of one.
- you'll need to decide what to do with URLs that have query strings as in file.php?query=string (treat separately or all increment file.php record).
That's a general overview and I realize that you may not be able to accomplish any single step yet based on that general info, so let's get you started. First, make sure you have everything you need
- a server that runs PHP and has a database
- adequate permissions to use .htaccess or to modify your php.ini file
Once verified, you'll need to create and test a prepended file.
Read up here to see if you can figure it out on you own'
[us2.php.net...]
[us2.php.net...]
[us2.php.net...]
Just test with something simple in the prepend file like
echo "Prepending";
Once you know it's working, go to the forum library [webmasterworld.com] and read up on the basics of extracting data using MySQL. That should be fun (I'm not being sarcastic - based on the fact that you said you're doing this from a desire to learn something new, it really should be fun).
When I tried
<?
auto_prepend_file "prefile.php";
?>
I got error message "unexpected T_CONSTANT_ENCAPSED_STRING" on the above line.
I checked the configuration for auto_prepend_file, there is 'no value' for both local value and Master value. Is this the reason for the error message?
I don't know if I have permission to use .htaccess. How can I check whether I have permission or not to use it? Sorry for being such a noob.
Thank you.
auto_prepend_fileis of type PHP_INI_PERDIR [php.net], which means the entry can be set in
php.ini,
.htaccessor
httpd.conf.
It is highly unlikely that your host is going to allow you to edit the
php.inior
httpd.confso you will need to find out if you are allowed to use per-directory override (
.htaccess) files.
$_SERVER [php.net] is an array containing information such as headers, paths, and script locations. The entries in this array are created by the webserver. There is no guarantee that every webserver will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the CGI 1.1 specification, so you should be able to expect those.