Re: [PHP] Writing to a file

2009-07-04 Thread Michael A. Peters
Jason Carson wrote: Yes, I am trying to write stuff to a file with PHP but in between the tags and without deleting what is already in the file. The only way is to read the file into memory, manipulate it there, and then rewrite it. Use a regex to get rid of the last closing tag, append

Re: [PHP] Writing to a file

2009-07-03 Thread Jason Carson
> On Fri, Jul 3, 2009 at 06:01, Jason Carson wrote: >> Hello everybody, >> >> How would I go about writing stuff to a file but in between the >> tags? > > The current industry standard is a combination of text editor and > keyboard, but there are many options. > > More specifically, are yo

Re: [PHP] Writing to a file

2009-07-03 Thread Daniel Brown
2009/7/3 Sándor Tamás (HostWare Kft.) : > The classic method is: > 1.) read the whole file into an array of strings. > 2.) search for the last line > 3.) insert a string BEFORE the last line. > 4.) write back the whole file to the same name > > Classic file handling does allow you to append to the

Re: [PHP] Writing to a file

2009-07-03 Thread Daniel Brown
On Fri, Jul 3, 2009 at 06:01, Jason Carson wrote: > Hello everybody, > > How would I go about writing stuff to a file but in between the > tags? The current industry standard is a combination of text editor and keyboard, but there are many options. More specifically, are you trying to wr

Re: [PHP] Writing to a file

2009-07-03 Thread Paul Scott
Jason Carson wrote: > How would I go about writing stuff to a file but in between the > tags? > http://www.php.net/file_put_contents -- Paul http://www.paulscott.za.net/ http://twitter.com/paulscott56 http://avoir.uwc.ac.za -- PHP General Mailing List (http://www.php.net/) To unsubscribe, vi

Re: [PHP] Writing to a file

2009-07-03 Thread Michael A. Peters
Jason Carson wrote: Hello everybody, How would I go about writing stuff to a file but in between the tags? Example, say I have config.php as follows... How would I go about adding stuff at the end of the file, but before the ?> tag? IMHO that's kind of dangerous. Better to have an xml f

Re: [PHP] Writing to a file

2009-07-03 Thread HostWare Kft.
these types of editing must be done in memory, because file handling does not allow inserts, deletes. SanTa - Original Message - From: "Jason Carson" To: Sent: Friday, July 03, 2009 12:01 PM Subject: [PHP] Writing to a file Hello everybody, How would I go about writing

Re: [PHP] Writing to a file

2009-07-03 Thread Stuart
2009/7/3 Jason Carson : > Hello everybody, > > How would I go about writing stuff to a file but in between the > tags? > > Example, say I have config.php as follows... > > > $hostname = "localhost"; > $database = "database"; > $username = "username"; > $password = "password"; > > ?> > > How would

[PHP] Writing to a file

2009-07-03 Thread Jason Carson
Hello everybody, How would I go about writing stuff to a file but in between the tags? Example, say I have config.php as follows... How would I go about adding stuff at the end of the file, but before the ?> tag? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http

Re: [PHP] writing to a file

2002-11-22 Thread Morgan Hughes
On Fri, 22 Nov 2002, Jason Wong wrote: > On Friday 22 November 2002 16:34, gamin wrote: > > Hello, > > file as the data is being written, not when the file is closed > I think you should try fclose() the file before you die! Or, if you need to force the data out to disk while writing, use fflu

Re: [PHP] writing to a file

2002-11-22 Thread Jason Wong
On Friday 22 November 2002 16:34, gamin wrote: > Hello, > > im running Red Hat 7.2 with PHP 4.0.6. How would i go about writing to a > file as the data is being written, not when the file is closed > > #!/usr/bin/php -q > > $fp=fopen('t', "a"); > if ($fp === false) > die("could not open file")

[PHP] writing to a file

2002-11-22 Thread gamin
Hello, im running Red Hat 7.2 with PHP 4.0.6. How would i go about writing to a file as the data is being written, not when the file is closed #!/usr/bin/php -q i tried the above, while it is running but 't' comes up as a blank (seen using ls). How would i go about putting the contents in 't'

Re: [PHP] Writing to a file that's not PHP_SELF

2002-08-15 Thread Analysis & Solutions
On Tue, Aug 13, 2002 at 04:02:51PM -0230, Kondwani Spike Mkandawire wrote: > > $file = fopen("Counter.txt", "r+"); > $counter = fread($file, filesize("Counter.txt")); > fwrite($file, "$counter", strlen($counter)); ... snip ... > // For some reason the updated value is not written > // to C

Fwd: [PHP] Writing to a file that's not PHP_SELF

2002-08-13 Thread Mike Dunlop
> $file = fopen("Counter.txt", "r+"); You need to open the file with write access and PHP must have write permission e.g. $file = fopen("Counter.txt", "w+"); Mike D... -- Mike Dunlop Webmaster Animation World Network [EMAIL PROTECTED] http://www.awn.com (323) 606-4238 office (323) 466

[PHP] Writing to a file that's not PHP_SELF

2002-08-13 Thread Kondwani Spike Mkandawire
Any idea why this is not working... $file = fopen("Counter.txt", "r+"); $counter = fread($file, filesize("Counter.txt")); fwrite($file, "$counter", strlen($counter)); echo ''; if(empty($SomeVariable...)){ $counter++; // Here counter indicates that it has been incremented... echo "cou

[PHP] writing to a file

2002-03-06 Thread Marc-Andre Vallee
Hi, Here is a foo.txt file : name=foo age=100 sex=y I want to open the file, find the age line, and then replace the 100 with another value. The only way i see, is to rewrite the entire file Maybe this is a stupid question, but, i tried the online doc, and saw nothing about this T

[PHP] writing to a file

2002-03-06 Thread Marc-Andre Vallee
Hi, Here is a foo.txt file : name=foo age=100 sex=y I want to open the file, find the age line, and then replace the 100 with another value. The only way i see, is to rewrite the entire file Maybe this is a stupid question, but, i tried the online doc, and saw nothing about this T

Re: [PHP] writing to a file

2001-03-25 Thread Mukul Sabharwal
heyo, http://devhome.net/php/tutorials/230101.html will be nice --- adam <[EMAIL PROTECTED]> wrote: > how do i write to the beginning of a file instead of > the end? > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional co

Re: [PHP] writing to a file

2001-03-25 Thread Felix Kronlage
On Sun, Mar 25, 2001 at 03:39:28AM -0800, adam wrote: > how do i write to the beginning of a file instead of the end? fseek will help. With it you con move the pointer to the file beginning. http://www.php.net/manual/en/function.fseek.php will have details. -fkr -- gpg-fingerprint: 076E 1E87

[PHP] writing to a file

2001-03-25 Thread adam
how do i write to the beginning of a file instead of the end? -- 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] writing to a file

2001-03-23 Thread hi
Hi, What was so difficult about implementing my last post? -- 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] writing to a file

2001-03-23 Thread Christian Reiniger
On Friday 23 March 2001 06:17, you wrote: > how would that look on a code view? i plan to write the variable > $message on top of the existing data > > > Don't even bother with that previous answer. You have what you want > > to write in a string, $new. Read the file and put that into another >

Re: [PHP] writing to a file

2001-03-22 Thread adam
nevermind ^^ i am jsut going to have posts that go from top to bottom oldest to newest -- 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] writing to a file

2001-03-22 Thread adam
how would that look on a code view? i plan to write the variable $message on top of the existing data ""hi"" <[EMAIL PROTECTED]> wrote in message 99ektl$gf0$[EMAIL PROTECTED]">news:99ektl$gf0$[EMAIL PROTECTED]... > Don't even bother with that previous answer. You have what you want to > write in

Re: [PHP] writing to a file

2001-03-22 Thread hi
Don't even bother with that previous answer. You have what you want to write in a string, $new. Read the file and put that into another string, $previous. Then concatenate the strings with the "." operator: $previous=$new . $previous and write $previous to the file. -- PHP General Mailin

Re: [PHP] writing to a file

2001-03-22 Thread David Robley
On Fri, 23 Mar 2001 12:39, adam wrote: > how might i write to a file called "comment.php.comment" and only write > the text specified to the top of the file, instead of writing it to the > bottom? You need several steps to achieve this: read all of comment.php.comment into an array open a temp f

[PHP] writing to a file

2001-03-22 Thread adam
how might i write to a file called "comment.php.comment" and only write the text specified to the top of the file, instead of writing it to the bottom? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]