1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

PHP script issue

Discussion in 'Software Development' started by theseus75, Jul 26, 2006.

Thread Status:
Not open for further replies.
  1. theseus75

    theseus75 Thread Starter

    Jan 7, 2005
    I applied a simple counter script into my site, but when I changed the html extension to php, going to the site brought the "access forbidden" message. I had to put in the exact URL (with the index.php on the end of the url) to get it to come up, though it worked once the page did come up. I even tried redirecting from the index to home.php.

    I embedded the code below into my index page, with the count.txt file in the same directory and with the 777 chmos. Thanks in advance for any help.


    $file = "count.txt";

    if (file_exists($file)) {
    $fp = fopen("$file", "r+");
    flock($fp, 1);
    $count = fgets($fp, 4096);
    $count += 1;
    fputs($fp, $count);
    flock($fp, 3);
    } else {
    echo "Can't find file, check '\$file'<BR>";

    <center>You are visitor number <b><?php echo $count; ?></b><br>
  2. spackler


    Mar 9, 1999
    Try loading a php page with something more simple like time display and call it time.php and see if that works.

    If that script is trying to write to the text file that might be your issue - check the permissions for that.
  3. brendandonhu


    Jul 8, 2002
    Are you using an Apache server?
    Create a file called .htaccess in that folder and put this in it:
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/486634

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice