PHP Text Hit counter

In case you have problems with some other PHPJunkyard script (not that there are THAT many).
Post Reply
AGlass0fMilk
Posts: 3
Joined: Sun May 09, 2010 10:43 pm

PHP Text Hit counter

Post by AGlass0fMilk »

Script: PHP text hit counter
Version: 1.3


Well, I've been trying to get the hit counter working on my website for a bit. But it's just not happening. When I run the test (http://glassdev.kbyet.com/Counters/Visi ... ?page=Home) I get my host's error page (which is annoying since it's full of pop-ups).

My Ftp client thing is net2ftp and I host on Kbyet (you have probably never heard of it). I have set the CHMOD to 666 but nothing gets written to, I don't even think the script gets run.

I have a simple PHP script set up so that the same HTML template is used for each page and the content I want on that page is put into the template, the PHP script simply puts the stuff in the template and then echo's it. I don't know if that's the problem, but I also put the Javascript execution code in the Pages Php file and it still doesn't work.

My website is http://glassdev.kbyet.com/

Is there anything that could be stopping this from working?

I don't feel like I gave much info, ask if you need it. Thank you.
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

On my site I have it working with the following settings:
counter folder (in your case that is the Visit folder) chmod 777
logs folder chmod 777
Home.txt chmod 666

on displaying the file http://glassdev.kbyet.com/Counters/Visit/logs/Home.txt it is indeed empty.
I saw that your javascript code for counter.php?page=Home is in the <head>...</head> section of your page. Mine is in the <body>...</body> section so that it also displays the count. Maybe that placing it in the <head>...</head> section is causing your problems (i have no time to test if that is true).

Greetings,
Henrie
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
AGlass0fMilk
Posts: 3
Joined: Sun May 09, 2010 10:43 pm

Post by AGlass0fMilk »

Well, putting it in the body didn't work either.

Could it be that my host prints "Hosted by Kbyet" at the bottom?
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

That could be it. At least now that I am well awake and I look at your sourcecode it is not right. The top of your page now is:

Code: Select all

<html>
<!--- Get out my source code! --->
<head>
<title>Glass Development Home</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link REL="SHORTCUT ICON" HREF="http://glassdev.kbyet.com/application_osx_terminal.ico">
<link rel="StyleSheet" type="text/css" media="screen" href="http://glassdev.kbyet.com/mystyle.css">
<link rel="StyleSheet" type="text/css" media="screen" href="http://glassdev.kbyet.com/newsStyle.css">
<!--- <head>
<script language="Javascript" src="http://glassdev.kbyet.com/Counters/Visit/counter.php?page=Home"></script>
</head> --->
<body>
Which is not how the code shoukld be, correct code would be:

Code: Select all

<html>
<!-- Get out my source code! -->
<title>Glass Development Home</title>
<meta http-equiv="Content-Language" content="English" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link REL="SHORTCUT ICON" HREF="http://glassdev.kbyet.com/application_osx_terminal.ico">
<link rel="StyleSheet" type="text/css" media="screen" href="http://glassdev.kbyet.com/mystyle.css">
<link rel="StyleSheet" type="text/css" media="screen" href="http://glassdev.kbyet.com/newsStyle.css">
<script language="Javascript" src="http://glassdev.kbyet.com/Counters/Visit/counter.php?page=Home"><!--
//--></script>
</head>
<body>
And you have this code on your page

Code: Select all

<!--- This page has been visited *count* times <br /> --->
Proper code would be

Code: Select all

<!-- This page has been visited *count* times <br /> -->
Comment tags have only 2 dashes instead of 3.
And if you want to place your counter here, you should move the javascript from the <head> to this location.

And I now tested, the javascript should also work when it is in your <head> section. It will than display the count nummer as the first character on your page.

And because your code is not valid now, it will not work.
But code printed by a hosting company insided your page is a known reason that scripts will not work. This is not always so, but it could very well be the reason that the counter script does not work.
You could try running a test server such as xampp on your own computer to see if the page works there.
If you don't like to test xampp you can look at this page http://www.portablefreeware.com/index.php?sc=125 to see if there is another local running webserver that you would like to test with.

Greetings,
Henrie
I do not monitor the Gbook forums regularly anymore since I do not use the Gbook script myself anymore for a long time. But it helped me a lot in learning to understand php.
AGlass0fMilk
Posts: 3
Joined: Sun May 09, 2010 10:43 pm

Post by AGlass0fMilk »

I got my website validated by W3 and fixed errors throughout. It still doesn't work, I think it might be my hosts banner thing.

I believe I know the host so I might be able to work out something where I manually put "Hosted by Kbyet" on all of my pages, but probably not since he would have to specifically change something just for me >.>

I'll do the tests you said, and if I do come to the conclusion that it is the host banner, I'll have to find some other alternative.

I might just have to go without using this PHP counter, it's not that important >.>
Post Reply