[PHP] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Dddogbruce \(@home.com\)

I'm writing a news script, and I just got it working earlier this
morning.  Now it writes the variables from the form to the .txt file;
but when I go to write again (another news article) it does it beside,
not above.  Me, thinking so brilliantly at 6AM, thought append would
mean above, but it means beside.  This is the script in working
condition, although it only writes one varibale since I was testing.
I'm not using mysql, only a .txt file and two PHP documents.

?
if( $formSubmit )
 {
echo "Your news has been processed.";
$newsSubmit = file( "news.txt" );
$fp = fopen( "news.txt", 'a' );
fwrite( $fp, $frmName );
fclose( $fp );
 }
else
 {
include ( "newsForm.php" );
 }
?

What I want it to do is post $frmName in the .txt file, and when another
entry is processed it will add that above.  I hope this is possible,
because I don't have access to a MySQL database *yet.*

Post all suggestions, please.

-Owen


-- 
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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Jack Dempsey

i believe there was a post about 10 messages ago regarding this same
problem--try fseek:
http://www.php.net/manual/en/function.fseek.php

-jack

-Original Message-
From: Dddogbruce (@home.com) [mailto:[EMAIL PROTECTED]]
Sent: Sunday, March 25, 2001 1:36 PM
To: [EMAIL PROTECTED]
Subject: [PHP] [PHP4] $fp = fopen( "news.txt", 'a' ); // 'a' = append!
Wah!


I'm writing a news script, and I just got it working earlier this
morning.  Now it writes the variables from the form to the .txt file;
but when I go to write again (another news article) it does it beside,
not above.  Me, thinking so brilliantly at 6AM, thought append would
mean above, but it means beside.  This is the script in working
condition, although it only writes one varibale since I was testing.
I'm not using mysql, only a .txt file and two PHP documents.

?
if( $formSubmit )
 {
echo "Your news has been processed.";
$newsSubmit = file( "news.txt" );
$fp = fopen( "news.txt", 'a' );
fwrite( $fp, $frmName );
fclose( $fp );
 }
else
 {
include ( "newsForm.php" );
 }
?

What I want it to do is post $frmName in the .txt file, and when another
entry is processed it will add that above.  I hope this is possible,
because I don't have access to a MySQL database *yet.*

Post all suggestions, please.

-Owen


--
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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Dddogbruce \(@home.com\)

Thanks for the quick reply, looking in to it!




-- 
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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Dddogbruce \(@home.com\)

Ok, with this fseek..

Could you give me an example of how to implement it?




-- 
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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Richard

You should find it on
http://www.php.net/manual/en/functions.fseek.php

Or something. There are examples that are quite clear.

- Richard

""Dddogbruce (@home.com)"" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ok, with this fseek..

 Could you give me an example of how to implement it?




 --
 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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Joe Brown

Re-create the file.  You're most of the way there.

if( $formSubmit )
 {
echo "Your news has been processed.";
$filename = "news.txt";

//This is simpler than messing with an array of the original content.
$fp = fopen ($filename, "r");
$newsSubmit  = fread ($fd, filesize ($filename));
fclose ($fp);

$fp = fopen( $filename, "w" );  // change append to write (a to w)
fwrite( $fp, $frmName );//write the new
fwrite( $fp, $newsSubmit);//write the old
fclose( $fp );
 }
else
 {
include ( "newsForm.php" );
 }

if you want to use fseek, then try this:

if( $formSubmit )
 {
echo "Your news has been processed.";
$filename = "news.txt";

//This is simpler than messing with an array of the original content.
$fp = fopen ($filename, "r+");
$newsSubmit  = fread ($fd, filesize ($filename));
fseek($fp,0);
fwrite( $fp, $frmName );//write the new
fwrite( $fp, $newsSubmit);//write the old
fclose( $fp );
 }
else
 {
include ( "newsForm.php" );
 }

""Dddogbruce (@home.com)"" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Ok, with this fseek..

 Could you give me an example of how to implement it?




 --
 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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Dddogbruce \(@home.com\)

When you say $newsSubmit  = fread ($fd, filesize ($filename));

Do you mean specify the filename?  $news.txt then?




-- 
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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Joe Brown

Take a closer look at the previous message I sent $filename was defined as:
$filename="news.txt";

""Dddogbruce (@home.com)"" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 When you say $newsSubmit  = fread ($fd, filesize ($filename));

 Do you mean specify the filename?  $news.txt then?




 --
 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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Dddogbruce \(@home.com\)

Oh.  Duh!  Thanks.  ;P

Joe Brown wrote:

 Take a closer look at the previous message I sent $filename was defined as:
 $filename="news.txt";

 ""Dddogbruce (@home.com)"" [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  When you say $newsSubmit  = fread ($fd, filesize ($filename));
 
  Do you mean specify the filename?  $news.txt then?
 
 
 
 
  --
  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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Dddogbruce \(@home.com\)

$fp = fopen ($filename, "r");
$newsSubmit  = fread ($fd, filesize ($filename));

These are giving me a parse error:
Warning: Supplied argument is not a valid File-Handle resource in
C:/XITAMI/owen/website/php/newsSubmit.php on line 10







-- 
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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Joe Brown

maybe spinning the 'd' in $fd 180 degrees to make it a p will help...

Sorry, haven't tried this myself, typo's happen.

heh, I'm still trying to compile php 4 windows :-(  been hoping for a
helping hand.


""Dddogbruce (@home.com)"" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 $fp = fopen ($filename, "r");
 $newsSubmit  = fread ($fd, filesize ($filename));

 These are giving me a parse error:
 Warning: Supplied argument is not a valid File-Handle resource in
 C:/XITAMI/owen/website/php/newsSubmit.php on line 10







 --
 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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Dddogbruce \(@home.com\)

I'm such a pest.  g



-- 
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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Dddogbruce \(@home.com\)

Ok, it wrote, but didn't write above.. *grins*




-- 
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] [PHP4] $fp = fopen( news.txt, 'a' ); // 'a' = append! Wah!

2001-03-25 Thread Dddogbruce \(@home.com\)

Ok, I'll get this eventually.  groan



-- 
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]