> But _why_ do you need to write to the root directory? Why not > just write to a directory where you *do* have permission to write to?
I can already do that. My problem is that I need to move or copy/delete the file from the place I do have permission to write to to the root. I have generated a PHP page but it is no good where it is, I need to automatically move this page and because the owner of the page is HTTPD and NoGROUP it doesn't let me. I get permission errors. I have tried chmod() and chown() the files I've written also to no avail. I'd really appreciate help because I don't know much at all about permissions, changing them or how I can automatically do this. Below is the code I have worked out up to now to generate the page. It's the part after the string which I have now tried about 60 different ways to adjust! function generate_page($formid, $pagename) { // Give the function the string to be generated including formid passed from // previous form $string = "<?php \$SECTION_NAME = \"goldfish_cms.php\"; // include the files from output fns to get functions which design the page include ('output_fns.php'); db_connect(); \$query = \"select * from goldfish_content where PageID='$formid'\"; \$result = mysql_query(\$query) or die(\"Error: Query failure with<BR>\$query<BR>\".mysql_error()); while (\$array = mysql_fetch_array(\$result)) { \$HeadTitle = \"\{\$array[\"HeadTitle\"]}\"; \$PageTitle = \"\{\$array[\"Title\"]}\"; \$BodyText = \"\{\$array[\"BodyText\"]}\"; \$Picture1 = \"\{\$array[\"PictureOne\"]}\"; \$Picture2 = \"\{\$array[\"PictureTwo\"]}\"; \$CatID = \"\{\$array[\"CatID\"]}\"; } // carry the variable head title in the page and do the page header do_html_header(\$HeadTitle); // carry variables into do_html_index() function in output_fns. // Page title = The headline of the page // Body text = The text body, can include html commands. // Picture 1 = picture or graphic that appears above the title if required. // Picture 2 = Picture that appears right hand side on the basic output_fns // CatID = Category which is used for determining which links appear on each page // Section name = Allows you to specify extra functions to output_fns.php to be unique to the page (requires hard coding) do_html_index(\$PageTitle, \$BodyText, \$Picture1, \$Picture2, \$CatID, \$SECTION_NAME); // put the page footer in position do_html_footer(); ?>"; // Define the filename to write to. $filename = 'test.txt'; // Open the file for overwriting. $fp = fopen($filename, "w"); // Write the string to the file $write = fputs($fp, $string); // Close the file fclose($fp); // copy the page as a php file $fp2 = fopen($filename, "r"); $root = "/home/root/"; copy($filename, $root); // rename the filename in the root directory to the pagename rename($filename, "$pagename.php"); fclose($fp2); // end of function. } // call the functions. generate_page($formid, $pagename); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php