Hi all, I finally got a text file to append on WAMP but when I uploaded live and set the chmod of text.php to 777 and text.txt to 777 it doesn't work and I get this error: 500 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. Apache/2.2.19 (Unix) mod_ssl/2.2.19 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server at conroy.ie Port 80 Please help
You'll have to look in the Apache error log to see which line of text.php threw the error. Then we can help you. Unless you're trying to write to a file you have no write permission to (and chmodding text.txt to 777 eliminates that possibility), the error has nothing to do with file permissions. (It looks as if you're mixing "text" and "text". Make sure the file this code is from is named test.php, not text.php and the text file is named test.txt, not text.txt.) Also, you might want to close the form, and provide a means of submitting it: ?php $saving = $_REQUEST['saving']; if ($saving == 1) { $data = $_POST['data']; $file = "test.txt"; $fp = fopen($file, "w") or die("Couldn't open $file for writing!"); fwrite($fp, $data) or die("Couldn't write values to file!"); fclose($fp); echo "Updated News Section Successfully."; } ?> <form name="form1" method="post" action="test.php?saving=1"> <textarea name="data" cols=110 rows="20"> <input type="submit" value="Submit" /> <?php $file = "test.txt"; if (!empty($file)) { $file = file_get_contents("$file"); echo $file; } ?> </form> PHP:
Hi Rukbat, I have them closed off in my file. The filenames are both correct. I went into the errorlog and it said "file not found" so I put the entire http:// address in and suddenly, Eureka, it works! Brilliant! Thanks very much for the help