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
?php ? 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 your new lines to 
 it, and then write it.


You probably want to do it atomic or you can end up with occasional 
issues (broken pages that requested the file you are writing before it 
is finished being written) and I don't know if php can do that.


Again that's where using a non php config file that is parsed by php.
You can make your edits, save the file to cache (IE APC) and then write 
it. Files that need its contents can get it out of cache and only need 
to read it from file if it isn't cached. Since you cache it before 
writing, it will be in cache while it is being written.


Another advantage to not using php for the file, you can validate the 
values before setting/using them and handle problems appropriately in 
your code rather than have a completely broken site because the script 
that wrote the file had a bug causing a ; not to be written under 
certain conditions.


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



[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 ?php ?
tags?

Example, say I have config.php as follows...

?php

$hostname = localhost;
$database = database;
$username = username;
$password = password;

?

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://www.php.net/unsub.php



Re: [PHP] Writing to a file

2009-07-03 Thread Stuart
2009/7/3 Jason Carson ja...@jasoncarson.ca:
 Hello everybody,

 How would I go about writing stuff to a file but in between the ?php ?
 tags?

 Example, say I have config.php as follows...

 ?php

 $hostname = localhost;
 $database = database;
 $username = username;
 $password = password;

 ?

 How would I go about adding stuff at the end of the file, but before the
 ? tag?

Remove the ? tag - it's not required if it's the last thing in the file.

-Stuart

-- 
http://stut.net/

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



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 ?php ?
tags?

Example, say I have config.php as follows...

?php

$hostname = localhost;
$database = database;
$username = username;
$password = password;

?

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

config
dbconfig
  hostname value=localhost /
  database value=database /
  username value=username /
  password value=password /
/dbconfig
/config

and read it into a DOM object via DOMDocument.
Then you can add things to the DOM
by making them children of the config node - and write the whole dom 
back to file.


That way your web app does not have write permission to a file that gets 
executed, and you can potentially cache the DOMDocument object in memory 
so it doesn't have to read from file every page load to get your 
settings (not tried that yet myself but I don't see why you couldn't).


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



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 ?php ?
 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, visit: http://www.php.net/unsub.php



Re: [PHP] Writing to a file

2009-07-03 Thread Daniel Brown
On Fri, Jul 3, 2009 at 06:01, Jason Carsonja...@jasoncarson.ca wrote:
 Hello everybody,

 How would I go about writing stuff to a file but in between the ?php ?
 tags?

The current industry standard is a combination of text editor and
keyboard, but there are many options.

More specifically, are you trying to write to a PHP file *with*
PHP?  And if so, would this be the kind of file you're trying to write
(such as creating an automated installer with auto-config)?

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

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



Re: [PHP] Writing to a file

2009-07-03 Thread Daniel Brown
2009/7/3 Sándor Tamás (HostWare Kft.) sandorta...@hostware.hu:
 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 end of a file, or
 recreate as a whole.
 Usually these types of editing must be done in memory, because file handling
 does not allow inserts, deletes.

Please don't top-post in threads.  It makes them difficult to read
for folks searching the archives.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Check out our great hosting and dedicated server deals at
http://twitter.com/pilotpig

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



Re: [PHP] Writing to a file

2009-07-03 Thread Jason Carson
 On Fri, Jul 3, 2009 at 06:01, Jason Carsonja...@jasoncarson.ca wrote:
 Hello everybody,

 How would I go about writing stuff to a file but in between the ?php ?
 tags?

 The current industry standard is a combination of text editor and
 keyboard, but there are many options.

 More specifically, are you trying to write to a PHP file *with*
 PHP?  And if so, would this be the kind of file you're trying to write
 (such as creating an automated installer with auto-config)?

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 Check out our great hosting and dedicated server deals at
 http://twitter.com/pilotpig


Yes, I am trying to write stuff to a file with PHP but in between the
?php ? tags and without deleting what is already in the file.


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



[PHP] writing a pdf file to the filesystem

2004-08-31 Thread Merlin
Hi there,
I am trying to write a pdf file which is created by a php script to the 
filesystem.

Here is the end of the php file which creates the pdf document:
.
.
.
$pdf_close($pdf);
$data = pdf_get_buffer($pdf);
Can anybody tell me how to save the file instead of printing it out 
directly?

Thank you for any hint,
Merlin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] writing a pdf file to the filesystem

2004-08-31 Thread Stut
On Tue, 31 Aug 2004 12:58:49 +0200, Merlin [EMAIL PROTECTED] wrote:
 I am trying to write a pdf file which is created by a php script to the
 filesystem.
 
 Here is the end of the php file which creates the pdf document:
 
 $pdf_close($pdf);
 $data = pdf_get_buffer($pdf);

$fp = fopen('file.pdf', 'w');
if ($fp)
{
fwrite($fp, $data);
fclose($fp);
}
else
print 'Failed to open file for writing';

-- 
Stut

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



[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
?

$fp=fopen('t', a);
if ($fp === false)
  die(could not open file);

for($i=0; $i10; $i++)
{
  $time= date(D, Ymd. G:i:s);
  $time = $time.\n;
  $result = fwrite($fp, $time, strlen($time));
  if ($result == -1)
 die(error writing to file);
//  if ($condition) die;  -- in case this happens i would like to have the
times outputted to the file 't'
  sleep(2);
}

fclose($fp);

?

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' when they are
written to the file

thx in advance

gamin.



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




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);

 for($i=0; $i10; $i++)
 {
   $time= date(D, Ymd. G:i:s);
   $time = $time.\n;
   $result = fwrite($fp, $time, strlen($time));
   if ($result == -1)
  die(error writing to file);
 //  if ($condition) die;  -- in case this happens i would like to have the
 times outputted to the file 't'
   sleep(2);
 }

 fclose($fp);

 ?

 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' when they are
 written to the file

I think you should try fclose() the file before you die!

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Mieux vaut tard que jamais!
*/


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




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
  fflush()...

-- 
   Morgan Hughes
   C programmer and highly caffeinated mammal.
   [EMAIL PROTECTED]
   ICQ: 79293356




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




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 Counter.txt

Because you already wrote $counter back to the file there in line 3.  
Nowhere in those three lines did you increment the counter before doing
the write.

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




[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 'form name=studVer action = ThisSameFile.php method=post';

if(empty($SomeVariable...)){
   $counter++;

//  Here counter indicates that it has been incremented...
   echo counter = $counter;

//  For some reason the updated value is not written
//  to Counter.txt
   fwrite($file, $counter, strlen($counter));
   fclose($file);

//  Again this indicates that the value of $counter
//  has actually gone up...
   echo counter = $counter;


I submit here...

The String in Counter.txt is always 0 why is this...



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




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-6619 fax
6525 Sunset Blvd.  GS10 Los Angeles, CA  90028
USA


[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

Thanks a lot

Marc-Andre Vallee
[EMAIL PROTECTED]




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




[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

Thanks a lot



--

Marc-Andre Vallee
[EMAIL PROTECTED]




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




RE: [PHP] Writing to text file from Radio Buttons

2002-01-22 Thread Niklas Lampén

fwrite()?


Niklas

-Original Message-
From: Harphajan Singh [mailto:[EMAIL PROTECTED]] 
Sent: 22. tammikuuta 2002 9:51
To: [EMAIL PROTECTED]
Subject: [PHP] Writing to text file from Radio Buttons


Greeting dudes ! I`m a fresh user of PHP and need some technical
assistance from you folks.

I`m creating a survey form(using radio buttons) and it
looks like this :-

Q1) How do you register for the hostel ?
input type=radio name=reg_method
value=phone By Phone 
INPUT type=radio name=reg_method
value=mail By E-Mail 
INPUT type=radio name=reg_method
value=office checked Walk-In to office

Q2)Do the authorities respond to your complaint
immediately?
INPUT type=radio name=responds value=yes Yes 
INPUT type=radio name=responds value=no
checked No

I would like to store each entry into a text file and
view them later.Hence, I would know the unique 'VALUE'
for a particular 'NAME'(for both the Q`s) So, the
output in my textfile should look something like

 date Value for Q1Value of Q2

I`m trying to open a file and then write to it for
instance :-

$fp = fopen($DOCUMENT_ROOT/.../software/survey.txt,
w);

BUT, I don`t really know how to store the unique
values for those radio buttons into my file.

Please help , dudes !


__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/

-- 
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] Writing to text file from Radio Buttons

2002-01-21 Thread Harphajan Singh

Greeting dudes ! I`m a fresh user of PHP and need some
technical assistance from you folks.

I`m creating a survey form(using radio buttons) and it
looks like this :-

Q1) How do you register for the hostel ?
input type=radio name=reg_method
value=phone By Phone 
INPUT type=radio name=reg_method
value=mail By E-Mail 
INPUT type=radio name=reg_method
value=office checked Walk-In to office

Q2)Do the authorities respond to your complaint
immediately?
INPUT type=radio name=responds value=yes Yes 
INPUT type=radio name=responds value=no
checked No

I would like to store each entry into a text file and
view them later.Hence, I would know the unique 'VALUE'
for a particular 'NAME'(for both the Q`s) So, the
output in my textfile should look something like

 date Value for Q1Value of Q2

I`m trying to open a file and then write to it for
instance :-

$fp = fopen($DOCUMENT_ROOT/.../software/survey.txt,
w);

BUT, I don`t really know how to store the unique
values for those radio buttons into my file.

Please help , dudes !


__
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/

-- 
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] Writing Array to File w/o blank lines

2002-01-13 Thread Andrew V. Romero

I have been working on a script that manipulates arrays and now I am
working on the part where the user can erase part of the array.
Previously the function  that writes the array to a file looked like:
function updateSuspenderOrVehicleFile($fileToUpdate, $newDataArray)
{
 $fileName = fopen( $fileToUpdate,w);
 for ($i=0; $icount($newDataArray); $i++)
 {
  //don't write blank lines left by remove feature
  if ($newDataArray[$i] != )
  {
   //check to see if on the last solution, if not add line break at end.

   if ($i+1 == count($newDataArray) || $newDataArray[$i +1] == )
fwrite($fileName,$newDataArray[$i]);
   else
fwrite($fileName,$newDataArray[$i]\r\n);
  }
 }
}

The problem is that when a user erases part of the array, I just set it
to array[$number] == , which works except in the following cases.
Lets say the user selects the last 2 array elements to erase, then when
the function is called to write the array, it leaves a couple blank
lines at the end of the file which messes up things later.  Originally I
though I would be easier to set the record they want to erase to , but
is there another way to say compress the whole array together or a
better way to do this?

Thanks for any ideas,
Andrew V. Romero


-- 
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] Writing array to file w/o blanks- Update

2002-01-13 Thread Andrew V. Romero

Oops the function had one mistake in it (from me already trouble
shooting this), it should be:
function updateSuspenderOrVehicleFile($fileToUpdate, $newDataArray)
{
 $fileName = fopen( $fileToUpdate,w);
 for ($i=0; $icount($newDataArray); $i++)
 {
  //don't write blanks left by remove feature
  if ($newDataArray[$i] != )
  {
   //check to see if on the last solution, if not add line break at end.

   if ($i+1 ==
count($newDataArray))
//the older email had an OR statement here
fwrite($fileName,$newDataArray[$i]);
   else
fwrite($fileName,$newDataArray[$i]\r\n);
  }
 }
}

Thanks,
Andrew V. Romero


-- 
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 Array to File w/o blank lines

2002-01-13 Thread Philip Olson

Hello Andrew-

This can be solved here or better yet, solved from the place that removes
the array elements.  Use unset() for that:

  unset($arr[$key]);

Now, when you loop through the array it'll have no empty elements.  
Rather then use for(), consider foreach() as it relies on no counts.  
But, in this case, I'd most likely create a string first then fwrite()
just once.  Something like:

  $data = implode(\n, $array);

Also, consider renaming the function/vars to something a bit more generic,
such as createFile or createFileFromArray but anyway, just an opinion :)  
And, use fclose().  Also for good measure, you may want to check if $file
is_writable() first.

Regards,
Philip Olson

p.s. Please keep questions to one thread.


On Sun, 13 Jan 2002, Andrew V. Romero wrote:

 I have been working on a script that manipulates arrays and now I am
 working on the part where the user can erase part of the array.
 Previously the function  that writes the array to a file looked like:
 function updateSuspenderOrVehicleFile($fileToUpdate, $newDataArray)
 {
  $fileName = fopen( $fileToUpdate,w);
  for ($i=0; $icount($newDataArray); $i++)
  {
   //don't write blank lines left by remove feature
   if ($newDataArray[$i] != )
   {
//check to see if on the last solution, if not add line break at end.
 
if ($i+1 == count($newDataArray) || $newDataArray[$i +1] == )
 fwrite($fileName,$newDataArray[$i]);
else
 fwrite($fileName,$newDataArray[$i]\r\n);
   }
  }
 }
 
 The problem is that when a user erases part of the array, I just set it
 to array[$number] == , which works except in the following cases.
 Lets say the user selects the last 2 array elements to erase, then when
 the function is called to write the array, it leaves a couple blank
 lines at the end of the file which messes up things later.  Originally I
 though I would be easier to set the record they want to erase to , but
 is there another way to say compress the whole array together or a
 better way to do this?
 
 Thanks for any ideas,
 Andrew V. Romero
 
 
 -- 
 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] 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-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 3E05 1C7F B1A0  8A48 0D31 9BD3 D9AC 74D0 
  |http://www.hazardous.org/ | whois -h whois.ripe.de FKR-RIPE  |
  |all your base are belong to us  |  shame on me  | fkr@IRCnet | 

 PGP signature


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 commands, e-mail:
 [EMAIL PROTECTED]
 To contact the list administrators, e-mail:
 [EMAIL PROTECTED]
 


=
To find out more about me : http://www.geocities.com/mimodit
My bookmarks are available @ http://mukul.free.fr

__
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

-- 
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
  string, $previous.  Then concatenate the strings with the "."
  operator:
 
  $previous=$new . $previous
 
  and write $previous to the file.

Well, he just gave you a detailed description of what to do. Everything 
else you need to know is in the manual.

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

"Never doubt that a small group of thoughtful, committed people can
change the world...
Indeed, it's the only thing that ever has."

- Margaret Mead

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




[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]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




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 file to write
write the 'text specified' to the temp file
write the array from comment.php.comment to the temp file
once you're happy all is written, close open temp file
rename temp file to comment.php.comment

The functions you need for this can be found in the Filesystem section of 
the docs.

-- 
David Robley| WEBMASTER  Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet| http://auseinet.flinders.edu.au/
Flinders University, ADELAIDE, SOUTH AUSTRALIA

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