I have a small website on a small companies hosting server. They have PHP Version 4.3.8 running on a SunOS system which I understand is an older text-based UNIX that runs on Sun SPARC (whatever all this means).

In testing out a simple guestbook which should write data to a guestbook.txt file, I keep getting an error message. My code on line 75 is:

$fp=fopen("guestbook.txt","a");

The error message I get on this line is:

Warning: fopen(guestbook.txt): failed to open stream: Permission denied in /u1/st/city/username/public_html/guestbook.php on line 75

The "guestbook.txt" file is on the server in the same directory as my "guestbook.php" file.

Any help would be appreciated.

    You will probably have to set the permissions of guestbook.txt so that all users can read it, as in most web installations PHP scripts are run by a generic webserver user, not by your personal user account. (On Linux/UNIX servers, you'd give it '644' permission, i.e. read/write for the owner and read for group and world.)

      Thanks NogDog.

      How does one set the permission?

        Depends on the platform and how your web site account is set up. You may be able to do it via whatever "control panel" your site uses, or if you access it via an FTP tool, many such tools provide an option (often via the right-click menu) to change the permissions.

          If you run vista...

          logon to your files using ftp, view in file explorer. Right Click the file - Properties then tick all boxes.

            Thanks much NoDog and benracer. I run XP, but the Right Click on the file gave me the properties where I was able to tick all the boxes.

            The text file now opens fine and I can write to it.

            Another problem has appeared so now I'll try to figure that one out.

              Write a Reply...