Hi, when I do that, nothing is written to news.txt, and I'm not sure why. This is the entire script:
<?php if ($_POST['news']) { $fp = fopen( "news.txt", "w"); $success = fwrite( $fp, "$POST_['news']" ); fclose($fp); if (!success) { echo "<p>unable to write to news.txt</p>"; exit; } Header("Location: http://archives1.mdah.state.ms.us/news.php" ); } ?> <html> <head><title>News update</title></head> <body bgcolor=white> <p>Please make your changes below and then click submit:</p> <?php if ( $_GET['action'] = "update") { echo "<form action=$PHP_SELF METHOD=POST>"; echo "<textarea name=news rows=10 cols=50 wrap=virtual>"; $fp = fopen( "news.txt", 'r' ); while ( ! feof ($fp) ) { $line = fgets( $fp, 9999 ); $line = htmlspecialchars(nl2br($line)); echo "$line"; } echo "</textarea> <br> <input type=submit value=submit name=submit> </form>"; fclose($fp); } ?> <a href="http://archives1.mdah.state.ms.us/news.php">home</a> </body></html> Adam On Tue, 1 Jul 2003, Adrian wrote: > you should use $_POST['news'] instead of "$POST_['news']". > ans you also should'nt put " around variables ;) > > ------------------------ > > Hello, > > > I have a block of code: > > > <?php > > if ($_POST['news']) > > { > > $fp = fopen( "news.txt", "w"); > > $success = fwrite( $fp, "$POST_['news']" ); > > fclose($fp); > > > if (!success) > > { > > echo "<p>unable to write to news.txt</p>"; > > exit; > > } > > > Header("Location: http://archives1.mdah.state.ms.us/news.php" ); > > } > ?>> > > > and when I access it, I get the error: > > > Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or > > `T_NUM_STRING' in /usr/local/apache2/htdocs/updatenews.php on line 5 > > > and line 5 is: > > > $success = fwrite( $fp, "$POST_['news']" ); > > > which looks ok to me. When I take out the " " around $POST_['news'] it > > doesn't generate an error, but then it doesn't write anything to news.txt. > > news.txt is owned by nobody with 755 and apache runs as nobody. > > > I'd appreciate any help. Thanks! > > > Adam > > > > ------------------------ > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php