Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Noah
Forum Newbie
Posts: 7
Joined: Sat Jun 19, 2004 3:34 pm

Help

Post by Noah »

When I try to run my script on my website I get these errors.

Warning: fopen(count.txt): failed to open stream: Permission denied in /home/noah0504/public_html/index.php on line 39

Warning: fgets(): supplied argument is not a valid stream resource in /home/noah0504/public_html/index.php on line 40

Warning: fclose(): supplied argument is not a valid stream resource in /home/noah0504/public_html/index.php on line 46

When I run the script on my local machine, It runs just fine. What's the problem?

Here's my code.

Code: Select all

<?php
session_start();

$fp = fopen("count.txt", "r+");
$count = fgets($fp);
if ( !session_is_registered("counted") ) {
    fseek($fp, 0, SEEK_SET);
    fwrite($fp, ++$count);
    session_register("counted");
}
fclose($fp);
echo $count;
?>
[edit=Weirdan] Noah, use

Code: Select all

tags! [/edit] [/color]
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

You have no permission to create the file or overwrite it. This is the problem.
User avatar
Noah
Forum Newbie
Posts: 7
Joined: Sat Jun 19, 2004 3:34 pm

Post by Noah »

How do I set the permission?
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

User avatar
Noah
Forum Newbie
Posts: 7
Joined: Sat Jun 19, 2004 3:34 pm

Post by Noah »

I've done all of that.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

Post by Joe »

Set the CHMOD of the file to something like 777. CuteFTP can set CHMOD's at the click of a button!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

...if the ftp server supports CHMOD, that is.
User avatar
tim
DevNet Resident
Posts: 1165
Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio

Post by tim »

some ftp servers dont support that joe, so it may not be as easy as u made it out to be.

edit, man feyd thats twice u beat me in like, 3 mins. Drink some coffee and let me post, :lol: :lol: :lol:
Post Reply