Re: [PHP] please help with this simple problem

2001-03-22 Thread adam

i tryed it and it ended up having an error that was caused originally by a
lack of a $ on the 3rd line variable... after i fixed that it said wrong
perameter count for fopen() on the third line, and "Warning: Supplied
argument is not a valid File-Handle resource" for the remaining lines below
that in that block of code.

i'm sorry, i'm kinda new to this : (

"Stewart Taylor" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 You need to copy the contents of the current file.
 Then recreate the file by writing the new message then writing back the
 original contents.

 e.g.
 $fname = basename($PHP_SELF). ".comment";
 $fsize = filesize($fname);
 fp = fopen(basename($fname));
 $data = fread($fp,fsize);
 fwrite($fp,$message);
 fwrite($fp,$data);
 fclose($fp);

 -Stewart

 -Original Message-
 From: adam [mailto:[EMAIL PROTECTED]]
 Sent: 22 March 2001 11:17
 To: [EMAIL PROTECTED]
 Subject: [PHP] please help with this simple problem


 i am coding a simple script to post a text area into a file. it works, but
 it posts it at the bottom and i wanted to have it post to the top of the
 text already there..

 here's a snip of the important part of the script:

 $fp = fopen (basename($PHP_SELF) . ".comment", "a");
  fwrite ($fp, $message);
  fclose ($fp);
  }

 any help would be much appreciated



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] please help with this simple problem

2001-03-22 Thread rui


you haven't specified the open type (a = append, w = write, r = read only , etc
etc)

solution

$fp=fopen(basename($fname), "a");

just to match your example.

On 22-Mar-2001 adam wrote:
 i tryed it and it ended up having an error that was caused originally by a
 lack of a $ on the 3rd line variable... after i fixed that it said wrong
 perameter count for fopen() on the third line, and "Warning: Supplied
 argument is not a valid File-Handle resource" for the remaining lines below
 that in that block of code.
 
 i'm sorry, i'm kinda new to this : (
 
 "Stewart Taylor" [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 You need to copy the contents of the current file.
 Then recreate the file by writing the new message then writing back the
 original contents.

 e.g.
 $fname = basename($PHP_SELF). ".comment";
 $fsize = filesize($fname);
 fp = fopen(basename($fname));
 $data = fread($fp,fsize);
 fwrite($fp,$message);
 fwrite($fp,$data);
 fclose($fp);

 -Stewart

 -Original Message-
 From: adam [mailto:[EMAIL PROTECTED]]
 Sent: 22 March 2001 11:17
 To: [EMAIL PROTECTED]
 Subject: [PHP] please help with this simple problem


 i am coding a simple script to post a text area into a file. it works, but
 it posts it at the bottom and i wanted to have it post to the top of the
 text already there..

 here's a snip of the important part of the script:

 $fp = fopen (basename($PHP_SELF) . ".comment", "a");
  fwrite ($fp, $message);
  fclose ($fp);
  }

 any help would be much appreciated



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

   Rui Barreiros
  Software Developer

WEBSOLUT - Soluções Internet
Emailto: [EMAIL PROTECTED] 
Personal Info: http://websolut.net/people/rui.html

As informações contidas neste email são confidenciais
e destinam-se apenas à(s) pessoa(s) a quem foi enviado:
http://websolut.net/confidencialidade-responsabilidade.html


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] please help with this simple problem

2001-03-22 Thread Stewart Taylor


Sorry I missed "w+" from the fopen function

$fname = basename($PHP_SELF). ".comment";
$fsize = filesize($fname);
$fp = fopen(basename($fname),"w+");   --- added "w+"
$data = fread($fp,$fsize);
fwrite($fp,$message);
fwrite($fp,$data);
fclose($fp)

-Stewart

-Original Message-
From: adam [mailto:[EMAIL PROTECTED]]
Sent: 22 March 2001 12:00
To: [EMAIL PROTECTED]
Subject: Re: [PHP] please help with this simple problem


i tryed it and it ended up having an error that was caused originally by a
lack of a $ on the 3rd line variable... after i fixed that it said wrong
perameter count for fopen() on the third line, and "Warning: Supplied
argument is not a valid File-Handle resource" for the remaining lines below
that in that block of code.

i'm sorry, i'm kinda new to this : (

"Stewart Taylor" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 You need to copy the contents of the current file.
 Then recreate the file by writing the new message then writing back the
 original contents.

 e.g.
 $fname = basename($PHP_SELF). ".comment";
 $fsize = filesize($fname);
 fp = fopen(basename($fname));
 $data = fread($fp,fsize);
 fwrite($fp,$message);
 fwrite($fp,$data);
 fclose($fp);

 -Stewart

 -Original Message-
 From: adam [mailto:[EMAIL PROTECTED]]
 Sent: 22 March 2001 11:17
 To: [EMAIL PROTECTED]
 Subject: [PHP] please help with this simple problem


 i am coding a simple script to post a text area into a file. it works, but
 it posts it at the bottom and i wanted to have it post to the top of the
 text already there..

 here's a snip of the important part of the script:

 $fp = fopen (basename($PHP_SELF) . ".comment", "a");
  fwrite ($fp, $message);
  fclose ($fp);
  }

 any help would be much appreciated



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] please help with this simple problem

2001-03-22 Thread adam

it works now, only it's earasing everything and then writing to the file.
i think we have almost got this figured out. here's what the code looks like
for the entire tag...
---

?
if ($message)
 {
 /* uncomment the next two lines to strip out html from input */
 $name = strip_tags($name);
 /* $message = strip_tags($message); */
 $message = ereg_replace("\r\n\r\n", "\nP", $message);
 $date = date("l, F j Y, h:i a");
 $message = "font size=2 face=verdanaba href=mailto:$email$name/a
/bfont size=1 -- $date/font\n
 blockquote\n
  $message\n
 /blockquote/font\nhr noshade color=white size=1 width=100%\n";

 $fname = basename($PHP_SELF) . ".comment";
 $fsize = filesize($fname);
 $fp = fopen(basename($fname),"w+");
 $data = fread($fp,$fsize);
 fwrite($fp,$message);
 fwrite($fp,$data);
 fclose($fp);

 }
@readfile(basename(($PHP_SELF . ".comment")));
?






""adam"" [EMAIL PROTECTED] wrote in message
99cmfj$mai$[EMAIL PROTECTED]">news:99cmfj$mai$[EMAIL PROTECTED]...
 i am coding a simple script to post a text area into a file. it works, but
 it posts it at the bottom and i wanted to have it post to the top of the
 text already there..

 here's a snip of the important part of the script:

 $fp = fopen (basename($PHP_SELF) . ".comment", "a");
  fwrite ($fp, $message);
  fclose ($fp);
  }

 any help would be much appreciated



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] please help with this simple problem

2001-03-22 Thread adam

it works now, only it's earasing everything and then writing to the file.
i think we have almost got this figured out. here's what the code looks like
for the entire tag...
---

?
if ($message)
 {
 /* uncomment the next two lines to strip out html from input */
 $name = strip_tags($name);
 /* $message = strip_tags($message); */
 $message = ereg_replace("\r\n\r\n", "\nP", $message);
 $date = date("l, F j Y, h:i a");
 $message = "font size=2 face=verdanaba href=mailto:$email$name/a
/bfont size=1 -- $date/font\n
 blockquote\n
  $message\n
 /blockquote/font\nhr noshade color=white size=1 width=100%\n";

 $fname = basename($PHP_SELF) . ".comment";
 $fsize = filesize($fname);
 $fp = fopen(basename($fname),"w+");
 $data = fread($fp,$fsize);
 fwrite($fp,$message);
 fwrite($fp,$data);
 fclose($fp);

 }
@readfile(basename(($PHP_SELF . ".comment")));
?








-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]