User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,553 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,841 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

Hit counter

Join Date: Jun 2007
Posts: 5
Reputation: tehgreatmg is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tehgreatmg tehgreatmg is offline Offline
Newbie Poster

Re: Hit counter

  #7  
Jun 21st, 2007
I am still lost. What I have is this in my html code
<script language="JavaScript" src="counter.php" type="text/JavaScript"></script>

and this php script
<?php
session_start ();

// get current hit
$opFile = fopen ("counter.txt", "r");
$handle = fread ($opFile, filesize ("counter.txt"));
fclose ($opFile);

// if new session
if (!isset ($_SESSION['hit'])){

// set session
$_SESSION['hit'] = TRUE;

// add the hit
$handle = $handle + 1;

// print javascript
echo 'document.write("'.$handle.' Hits");';

// put new hit to db
$opFile = fopen ("counter.txt", "w");
fwrite ($opFile, $handle);
fclose ($opFile);

// else
}else{

// print only
echo 'document.write("'.$handle.' Hits");';
}
?>

and then a file named counter.txt with only the value 0 in it. All three files are in my C:\inetpub\wwwroot folder

And when I open the webpage the number in counter.txt does not change and no counter is displayed on the page.
Reply With Quote  
All times are GMT -4. The time now is 6:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC