I am working with chapter 10 in wrox Beginning php 4 book. I am running
my test system on windows XP pro.

I believe this error is due to a permissions setting. But when I look at
the properties for the default web page read write and scripts are all
checked.

Error:
Warning: fopen(./counter.dat) [function.fopen]: failed to create stream:
Permission denied in c:\inetpub\wwwroot\testing\counter.php on line 21

Code
----
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>Simple Counter</title>
  </head>

  <body>
    <h1>Simple Counter</h1>
    <hr>
    <?php
    //counter.php
    $counter_file = "./counter.dat";
    if(!($COUNTER = fopen($counter_file, "r"))) die ("Cannot open
$counter_file.");
    $counter = (int) fread($COUNTER, 20);
    fclose ($COUNTER);

    $counter++;
    
    echo ( "You are visitor number $counter.");

    $COUNTER = fopen($counter_file, "w");
    fwrite ($COUNTER, $counter_file);
    fclose ( $COUNTER);
    ?>
    <address><a href="mailto:[EMAIL PROTECTED]"></a></address>
<!-- Created: Sun Apr 06 10:35:34 Eastern Standard Time 2003 -->
<!-- hhmts start -->
Last modified: Sun Apr 06 11:01:02 Eastern Standard Time 2003
<!-- hhmts end -->
  </body>
</html>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to