Re: [PHP] fwrite() question

2003-07-01 Thread Adrian
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 punable 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




-- 
Adrian
mailto:[EMAIL PROTECTED]
www: http://www.planetcoding.net
www: http://www.webskyline.de



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] fwrite() question

2003-07-01 Thread Adam Williams
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 punable to write to news.txt/p;
exit;
}

Header(Location: http://archives1.mdah.state.ms.us/news.php; );
}
?

html
headtitleNews update/title/head
body bgcolor=white
pPlease 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,  );
$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 punable 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



Re: [PHP] fwrite() question

2003-07-01 Thread Jason Wong
On Tuesday 01 July 2003 22:12, Adam Williams wrote:

 when I do that, nothing is written to news.txt, and I'm not sure why.

Well find out why!

 This is the entire script:

 ?php
 if ($_POST['news'])
 {
 $fp = fopen( news.txt, w);

Add some error-checking to see whether fopen() was successful. See examples in 
manual for details.

 $success = fwrite( $fp, $POST_['news'] );
  

As has already been pointed out you don't need the double-quotes.

And it should be $_POST['news'].

 fclose($fp);

 if (!success)

This should be: if (!$success)

And please trim your post!

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
We come to bury DOS, not to praise it.
(Paul Vojta, [EMAIL PROTECTED], paraphrasing a quote of Shakespeare)
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php