Wrox Programmer Forums
|
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2006, 07:57 AM
Registered User
 
Join Date: Feb 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.!!


Thanks :)
 
Old April 23rd, 2006, 06:25 AM
Authorized User
 
Join Date: May 2005
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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






Similar Threads
Thread Thread Starter Forum Replies Last Post
Hit Counter Help! NeilS21 Classic ASP Databases 4 April 29th, 2005 06:59 AM
hit counter gumgak Classic ASP Basics 2 November 2nd, 2003 12:44 AM
Hit Counter mateenmohd HTML Code Clinic 7 September 28th, 2003 07:22 AM





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