After thinking about it, this is probably the correct forum to post this ... sorry for the duplication ... anyway,

I am wanting to create static html pages from my mysql database tables. The route that I am attempting to take is to create a script that creates the directories and html files as needed. Like creating a category directory with multiple html files and directories beneath.

Using this method I will have to temporarily change file/directory permissions and feel this isn't the best route to go. Does anyone have any suggestions or can you direct me to some code on accomplishing this task? Is this something that I should really be doing only from the shell and not from site authenticated user pages? Any direction is appreciated.

Thanks,

Bill

    Well, you will have to change the permissions at least temporarily if you wish to go this route. It's been covered here many times and there is alot of useful information around here...search.

    create static

      Thanks for the reply. The part where I am really leary is creating directories and new files with the permissions. I have the page content generating to a variable. When I attempt to write to a new file, I run into permission problems. I can create the directory (if it doesn't exist) fine but when adding a file (fopen and the file doesn't exist) in that directory I get a permission error. I believe it has to do with being nobody. I am still combing through the articles. Do you by chance have any more specific direction?

      Thanks,

      Bill

        $handle = fopen("$path/$filename.php", 'a');
        fwrite($handle, $stuff);
        fclose($handle);

        I think this is what you are looking for. This will take your file contents and output stuff.

          That is what I have in my script but I get this error ...

          Warning: fopen("test.txt", "w") - Permission denied in /home/virtual/site54/fst/var/www/html/awritetest.php on line 5

          The script is running as nobody (if I am thinking right) and I think that is where my problem lies. If a file exists, it seems that I can overwrite it but if it is a new file, I get the above error.

          The only way that I have come up with to get around it is to create the directory with everyone having write privs (the part that I don't like) for a short period of time while I create the necessary files and then change it back. I toyed with umask but wasn't successful.

            Try putting the document root path in there...I believe I've been stuck on this before too and when I added the server path stuff it was fine. Also, try using 'a' as your string mode.

            http://be2.php.net/fopen

            I believe you are closer than you think...v

              I put the full path but still am getting the same error msg. I have tried all sorts of combinations. Any other ideas???

                It appears that 'html' is your root folder. Have you set the permissions on this - normally this would be a no-no. Move it up a folder level and try again...be sure you 0777 the folder...j

                  Write a Reply...