Page 1 of 2

What's the problem here?

Posted: Mon Sep 01, 2003 5:45 am
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

Posted: Mon Sep 01, 2003 6:03 am
by JayBird
basically, it looks like you have read permission on hits.txt, but not write permissions.

So, basically, check your permissions.

Mark

Posted: Mon Sep 01, 2003 6:37 am
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?

Posted: Mon Sep 01, 2003 6:48 am
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

Posted: Mon Sep 01, 2003 6:50 am
by Gonik
try chmoding the file hits.txt to 755 and the problem will solve

Posted: Mon Sep 01, 2003 1:09 pm
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) ?

Posted: Mon Sep 01, 2003 1:23 pm
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.

Posted: Mon Sep 01, 2003 1:45 pm
by JAM
fopen() problem.

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

Posted: Mon Sep 01, 2003 3:38 pm
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.

Posted: Mon Sep 01, 2003 3:48 pm
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.

Posted: Mon Sep 01, 2003 4:26 pm
by mudkicker
i read them all but i sitll dont have a clue. i'm stuck, man this is poisioning my php knowledge :lol:

Posted: Mon Sep 01, 2003 5:38 pm
by JAM
Sorry, wish I/we could be of more help.

If you find the answer, please let us know for later reference.

Posted: Tue Sep 02, 2003 2:12 am
by mudkicker
OK but i'm still asking for help if any other person can solve this, please reply this post. :roll: :cry:

Posted: Tue Sep 02, 2003 2:44 am
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

Posted: Tue Sep 02, 2003 2:51 am
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: