Welcome to Esato.com




counter on website question - IIS question added


Click to view updated thread with images




Posted by EastCoastStar
okay, i have added many counters to websites... (free, but not remotly hosted) I want to add my own. Normally when I do this, I have had a FTP to work with, this time, its going straight into the database on this computer/server and will load to the web right away. many things tell me to chmod (or change the premissions) im not sure how to do this without an FTP. does anyone know any good tutorials, or can help me putting a text based hit counter on a website VIA my database, not FTP? thanks!

[ This Message was edited by: EastCoastStar on 2005-11-02 17:13 ]


Posted by EastCoastStar
anyone? sorry ive been in a hurry latley lol

Posted by Johnex
You could make a counter with php and mysql if you want.

Posted by EastCoastStar
i tried that, but somewhere along the lines, i must have messed up. any other suggestions? ill go look into the mysql and php counters again and throw one together and see what happens.
thanks

Posted by Johnex
I could make you one when i get home, very simple to make. I would increment on refresh too though.

Posted by Rocky B.
What's wrong with remotely hosted solutions? I personally use http://www.statcounter.com - that's an absolutely fantastic service. Proper web analyctics, rather than merely counting the number of users.

Beyond that, server log files are also good

Posted by EastCoastStar
Quote:

On 2005-11-02 17:40:09, Rocky B. wrote:
What's wrong with remotely hosted solutions? I personally use http://www.statcounter.com - that's an absolutely fantastic service. Proper web analyctics, rather than merely counting the number of users.

Beyond that, server log files are also good




the people im making the website for want it to be all hosted under their server, nothing remotly hosted... just what they wanted haha, otherwise, i would probobly use statcounter (or fastcounter). ive never ran into problems making my own until today haha.

@johnex, if it will increment on refresh, thats fine, that doesnt matter too much to me. but i have tried a few counters with MySQL and PHP, but for some reason they wont work. if you make me one, i would be greatful (but, i might not use it honestly, maybe something is wrong with the server over here or something). if you do make one, the i can ask you about it, and all should work fine thank you much.

Posted by EastCoastStar
hrm... i just learned that the server is using IIS... (sumthn about SS also) so i have to confugure the IIS to run PHP... (wtf... what do i do?!)

Posted by Johnex
// PHP Counter © Johnex 2005
//=============================

//=======================//
// Database Table //
//=======================//
// Run this query in
// phpmyadmin or something...
//=========================

CREATE TABLE `wap_counter` (
`total_count` char(200) default NULL
);


//=======================//
// File: counter.php //
//=======================//
// Paste the following into
// a new file in notepad,
// save with "File Name"
// counter.php , and "Save
// As Type" as "All Files".
// Change the variables
// below to match your
// mysql settings.
//=========================

// Vars
$host = 'HOST'; // usually 'localhost'
$user = 'USERNAME'; // your MySQL Password
$pass = 'PASSWORD'; // your MySQL Username
$dbase = 'DATABASE NAME'; // whatever your database name is

// Mysql Connect
$conn = mysql_connect($host, $user, $pass)) or mysql_error();
mysql_select_db($dbase,$conn)) or mysql_error();

// Get Count
$get_count = mysql_query('SELECT * FROM counter',$conn) or mysql_error();
while ($total_count = mysql_fetch_array($get_count)) {
$count = $total_count['total_count'];
$new_count = $count + 1;
}
mysql_query("UPDATE counter SET total_count = '$new_count'",$conn) or mysql_error();

// Print
print'
<!--
function writeContent() {
'."document.getElementById('counter').innerHTML = '<b>Hits: $new_count</b>';".'
}
writeContent();
//-->
';

//=======================//
// HTML //
//=======================//
// Paste the code bellow where
// you want the counter to be
// displayed. Change the
// "src" to the folder where
// you put the counter.php
// file
===========================

<scrpt type="text/javascript" src="counter.php"></script>
<div id="counter"></div>

//=============================

Hope this helps dude

_________________
JPortal Beta
http://beta.johnex.se
------------------------
Test it out now!
------------------------
Formerly known as JohnN4

[ This Message was edited by: Johnex on 2005-11-02 19:18 ]

Posted by EastCoastStar
thanks!

a little confused... what is this part?

//=======================//
// Database Table //
//=======================//
// Run this query in
// phpmyadmin or something...
//=========================

CREATE TABLE `wap_counter` (
`total_count` char(200) default NULL
);

you said to run it in phpmyadmin, that confused me a little.


also, i added the php5 configuration to the IIS, so hopefully it will work fine

Posted by Johnex
Run that "query" in a mysql interface, i use phpmyadmin. I suggest you install it, http://www.phpmyadmin.net/home_page/

EDIT: Re-copy the script, i made a small change in the counter.php file.

_________________
JPortal Beta
http://beta.johnex.se
------------------------
Test it out now!
------------------------
Formerly known as JohnN4

[ This Message was edited by: Johnex on 2005-11-02 19:19 ]

Posted by EastCoastStar
the guys im workin with dont want me to get in with the SQL server, becuase they run alot on their SQL, and they are worried something might get messed up :- im looking for a non SSI and non mySQL solution :-\ hrm...

this would be so much easier if i was at home and could do it the way i wanted to hahaha



[ This Message was edited by: eastcoaststar on 2005-11-02 19:31 ]

Posted by Johnex
k, one sec then......

Posted by EastCoastStar
thanks, i owe you!

Posted by Johnex
// PHP Counter © Johnex 2005
//=============================

//=======================//
// File: counter.php //
//=======================//
// Paste the following into
// a new file in notepad,
// save with "File Name"
// counter.php , and "Save
// As Type" as "All Files".
// Change the variables
// below to match your
// mysql settings.
//=========================

// Make File, Read Count, Add 1, Write New Count
if(file_exists('count_file.txt')) {
$count_file = fopen('count_file.txt', r);
$count = fread($count_file, filesize('count_file.txt'));
$new_count = $count+1;
fclose($count_file);
$count_file = fopen('count_file.txt', w);
fwrite($count_file,$new_count);
fclose($count_file);
} else {
$count_file = fopen('count_file.txt', w);
fwrite($count_file, 1);
$new_count = '1';
fclose($count_file);
}

// Print
print'
<!--
function writeContent() {
'."document.getElementById('counter').innerHTML = '<b>Hits: $new_count</b>';".'
}
writeContent();
//-->
';

//=======================//
// HTML //
//=======================//
// Paste the code bellow where
// you want the counter to be
// displayed. Change the
// "src" to the folder where
// you put the counter.php
// file
===========================

<div id="counter"></div>
<scrpt type="text/javascript" src="counter.php"></script>

//=============================

Flat File Version


_________________
JPortal Beta
http://beta.johnex.se
------------------------
Test it out now!
------------------------
Formerly known as JohnN4

[ This Message was edited by: Johnex on 2005-11-03 15:02 ]

Posted by EastCoastStar
i know im giving you a hard time here! haha but...

// Make File, Read Count, Add 1, Write New Count

im not running an FTP... so how can u chance the permissions? (read count, add one, write new count)


edit: im beginning to think the server i am working with is crap hahaha
_________________
check out the site guys. www.editionfws.com

Proud Owner: T61d, T610 X 3, T630 X 2, a new S710
Moto V400, V600

Brand New PSP: Midnight Club 3 and Ape Escape (for my gf)

[ This Message was edited by: EastCoastStar on 2005-11-02 19:43 ]

Posted by EastCoastStar
see, i was trying with PHP, then i realized PHP wasnt installed in the IIS (becuase im running this through the server thats right next to me, i didnt buy webspace), so i installed and configured php5 to IIS 5.1 successfully. but the i right click a file, and try to change the permissions, and it wont let me. That makes no sence to me why it wont let me chance permissions to a file. Then, They dont want me to use MySQL/SQL... and in order to use MOST CGI and PHP scripts, i have to change permissions... so they are telling me there is a way to easily run a counter straight out of the server, but they dont know how to do it... hrm... ::screams::

Posted by Johnex
errr........i an change the permissions in php, but that would have to be done on every change, slowing down the site......do you really need to change the perms? the default 755 is fine.....people can view the count_file, but who cares! It will show on the site anyway...

Posted by EastCoastStar
i thought i needed to in order for it to work... hrm...

so all i have to do is... add all that into 'counter.php' that parts easy... then make the blank file called 'count_file.txt' then add the HTML onto the main index, and it should work fine, right? (btw, whered ur HTML to add go?!? lol)

and again, i apologize for makin this hard on you! lol

Posted by Johnex
Yeah, it should work . Use the previous posted html, but change the position of the two lines. First the div line, then the script line. EDIT: let me know how it goes .

[ This Message was edited by: Johnex on 2005-11-02 20:41 ]

Posted by EastCoastStar
still nothing nothing loads on the page, its like i never put the code there, but its in the HTML

Posted by Johnex
Whats the address? Pm it to me.

Posted by EastCoastStar
you got PM

Posted by Johnex
So do you :-).:-):-)

Posted by EastCoastStar
and back at yaaaaa

Posted by Johnex
.....and yet again.


Posted by EastCoastStar
and back again... maybe haha idk if u saw it yet lol

Posted by Johnex


Posted by Johnex
// PHP Counter © Johnex 2005
//=============================

//=======================//
// File: counter.php //
//=======================//
// Paste the following into
// a new file in notepad,
// save with "File Name"
// counter.php , and "Save
// As Type" as "All Files".
// Change the variables
// below to match your
// mysql settings.
//=========================

<?
// PHP Counter v2.0 © Johnex 2005
//=============================

// Make File, Read Count, Add 1, Write New Count
if(file_exists('count_file.txt')) {
$count_file = fopen('count_file.txt', r);
$count = fread($count_file, filesize('count_file.txt'));
$new_count = $count+1;
fclose($count_file);
$count_file = fopen('count_file.txt', w);
fwrite($count_file,$new_count);
fclose($count_file);
} else {
$count_file = fopen('count_file.txt', w);
fwrite($count_file, 1);
$new_count = '1';
fclose($count_file);
}

// Print
print'
<!--
function writeCounter() {
'."document.getElementById('counter').innerHTML = '<b>Hits: $new_count</b>';".'
}
//-->
';

?>

//=======================//
// HTML //
//=======================//
// Folow this "template", in the head
// tags of the source of the site write
// the script stuff, then, in the opening
// body tag, write the onload stuff.
// Lastly, paste the div stuff where
// you want the counter to be
// displayed. Change the
// "src" to the folder where
// the counter.php file is located
//===========================

<html>
<head>
<script type="text/javascript" src="counter.php"></script>
</head>
<body onload="writeCounter()">
<div id="counter"></div>
</body>
</html>

//=============================

Flat File Version v2.0

New changes to make it work, test it here: http://johnex.se/dev/counter/

Posted by EastCoastStar
almost got it... but... it wont increment for some odd reason?!? idk whats going on with it haha.
i want to try something, and see if it will work...

edit: hrm... still wont increment... i still get the 1 so i know it knows its there, but why it wont increment is beyond me...

[ This Message was edited by: EastCoastStar on 2005-11-03 18:21 ]

Posted by Johnex
You saw the link i have you right? That is how it should go. Hm..... Pm me the address to the page where you have the counter...

Posted by EastCoastStar
PM for u... yet again lol

Posted by Johnex
pm back

Posted by EastCoastStar
and once again lol


Click to view updated thread with images


© Esato.com - From the Esato mobile phone discussion forum