What's the problem here?

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

User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

What's the problem here?

Post by mudkicker »

This the code :

Code: Select all

<?php
$filename = "hits.txt"; 
$fd = fopen ($filename,"r") or die ("Uhoh! The PHP script cant open $filename"); 
$fstring = fread ($fd , filesize ($filename)) ; 
echo "<center>This site is visited $fstring times.</center>" ; 
fclose($fd) ; 

$fd2 = fopen ($filename,"w") or die ("Uhoh! The PHP script cant open $filename #2"); 
$fcounted = $fstring + 1 ; 
$fout= fwrite ($fd2 , $fcounted );
fclose($fd2) ; 
?>
And if i want to call this script it gives this error.

Code: Select all

This site is visited 28 times.
Uhoh! The PHP script cant open hits.txt #2PHP Warning: fopen(hits.txt): failed to open stream: Permission denied in C:\web\dnb\index.php on line 62
hits.txt includes the number 28!
I2m running PHP under IIS. I think it's a problem with IIS...

Thanks,
mudkicker
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

basically, it looks like you have read permission on hits.txt, but not write permissions.

So, basically, check your permissions.

Mark
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

yes i can see that but which permissions? this txt file doesn't have any permissions. is there a permission setting on iis or what?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

You can set permissions for any object in IIS, including Web sites, folders, files, and scripts. To set the permissions for an object in IIS:
  • Log on to the Web server computer as an administrator.
    Click Start, point to Settings, and then click Control Panel.
    Double-click Administrative Tools, and then double-click Internet Services Manager.
    Right-click the Web site that you want to configure in the left pane, and then click Properties.
    If you want to set the permissions for a Web site's home folder, click the Home Directory tab.
    If you want to set the permissions for a folder in a Web site, click the Directory tab.
    If you want to set the permissions for a file or a script in a folder, click the File tab.
    Click the corresponding permissions that you want to set for the object.
    Click OK
Last edited by JayBird on Mon Sep 01, 2003 6:52 am, edited 5 times in total.
User avatar
Gonik
Forum Newbie
Posts: 19
Joined: Fri Aug 30, 2002 7:39 am
Location: Somewhere Around Nothing

Post by Gonik »

try chmoding the file hits.txt to 755 and the problem will solve
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

still got the same errors...

gonik it's not on the server it's on my home computer and i dont have to chmod it.

bech100 can you be more specific, for example which permissions for whole website (all files and folders) ?
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

Actually, i have some problems with fopen() function....
it doesn't work. i use php 4.3.3 (new released) and iis under xp pro.

thanks for answers.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

fopen() problem.

Could you paste abit of the code, and perhaps an errormsg you get from using it?
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

JAM wrote:fopen() problem.

Could you paste abit of the code, and perhaps an errormsg you get from using it?

Code: Select all

Uhoh! The PHP script cant open hits.txt #2
PHP Warning: fopen(hits.txt): failed to open stream: Permission denied in C:\web\dnb\index.php on line 62
THis is the error output.
Code is above in my first post.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Oh, sorry. Totally missed that in your first post. =/

It really looks like an IIS issue, but my knowledge about that is not to good. http://se.php.net/manual/en/install.iis.php has some interesting user notes about user permissions that might be helpful.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

i read them all but i sitll dont have a clue. i'm stuck, man this is poisioning my php knowledge :lol:
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

Sorry, wish I/we could be of more help.

If you find the answer, please let us know for later reference.
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

OK but i'm still asking for help if any other person can solve this, please reply this post. :roll: :cry:
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

mm........you can't set permissions from XP Pro on IIS from what I know.

I installed my Windows Server 2003 just for that problem...

-Nay
User avatar
mudkicker
Forum Contributor
Posts: 479
Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:

Post by mudkicker »

Oh, no... Tell me it's just a dream that you wrote this... :cry:

Actually, I want to install this Server 2003 but I have no time. But if you say this, I gues I MUST.

:cry: :cry: :cry: :cry:
Post Reply