p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 (http://p2p.wrox.com/forumdisplay.php?f=33)
-   -   A Hit Counter, PLEASE HELP !!!!! (http://p2p.wrox.com/showthread.php?t=38511)

ARD_40 February 15th, 2006 07:57 AM

A Hit Counter, PLEASE HELP !!!!!
 
(Book:Beginning PHP4, ISBN 1861003730)
Hi, I have recently began learning PHP4 and enjoying the book. But time to time, end up hitting a 'brick wall'!!
Up to now, my problems were 'typo' errors, but this recent problem has got me well baffled, in Chapeter 10.
I am even getting an error, using the down loaded code!

My code is:
<?php
//hit_counter1.php
$counter_file = "./count.dat";
if(!($fp = fopen($counter_file, "r"))) die ("Cannot open $counter_file.");
$counter = (int) fread($fp, 20);
fclose($fp);

$counter++;

echo "You're visitor No. $counter.";

$fp = fopen($counter_file, "w");
fwrite($fp, $counter);
fclose($fp);
?>

The error message I get is:
You're visitor No. 1.
Warning: fopen(./count.dat): failed to open stream: Permission denied in c:\inetpub\wwwroot\hit_counter1.php on line 12

Warning: fwrite(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\hit_counter1.php on line 13

Warning: fclose(): supplied argument is not a valid stream resource in c:\inetpub\wwwroot\hit_counter1.php on line 14

Help !!!!!!! Befor I pull all my hair out! And there isn't many of them.!![V]


Thanks :)

dbdave April 23rd, 2006 06:25 AM

I see you use a local server. Check that count.dat has not been set with the "read only" attribute.



All times are GMT -4. The time now is 09:08 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.