# \[PHP\] Text file hit counter Problems

**URL:** <https://forum.kirupa.com/t/php-text-file-hit-counter-problems/79309>\
**Category:** programming\
**Created:** [February 12, 2005, 6:18pm UTC](https://forum.kirupa.com/t/php-text-file-hit-counter-problems/79309 "2005-02-12T18:18:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw06](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@jw06](https://forum.kirupa.com/u/jw06)\
**Post date:** [February 12, 2005, 6:18pm UTC](https://forum.kirupa.com/t/php-text-file-hit-counter-problems/79309/1 "2005-02-12T18:18:04Z")

</div>

Hrm, I have this snippet, that i got from a tutorial, to keep track of people visiting my site:

```php

<?php
   $fp = fopen ( "counter.txt" , "r" );
   $count = fread ( $fp , filesize( "counter.txt" ));
   fclose ( $fp );
   $count ++;
   $fp = fopen ( "counter.txt" , "w" );
   fwrite ( $fp , $count );
   fclose ( $fp );
?>

```

When I include it and actually go to my site it gives me the following errors:

Warning: fopen(“counter.txt”, “w”) - Permission denied in /home/portfolio/www/functions.php on line 48

Warning: Supplied argument is not a valid File-Handle resource in /home/portfolio/www/functions.php on line 49

Warning: Supplied argument is not a valid File-Handle resource in /home/portfolio/www/functions.php on line 50

([http://portfolio.arctichosts.com/](http://portfolio.arctichosts.com/) if you want to see for yourself)

Any idea on how I can fix this?
