473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

overwrite to file

Hi!,
I a php noob so sorry if this is a stupid question,
I have a little code that puts some data in a file
which works very well.
I want to instead of append to the file I want
to overwrite the contents of it.

??

-------------------existing code-------------------
<?php
$filename = "justatest.txt";
$output = "SOME_DATA_HERE";
$filehandle = fopen($filename, 'a');
fwrite($filehandle, $output);
fclose($filehandle);
?>
Jul 17 '05 #1
3 19286

"Jonny T" <jo****@someisp3.com> ???????/???????? ? ???????? ?????????:
news:c4*********@titan.btinternet.com...
Hi!,
I a php noob so sorry if this is a stupid question,
I have a little code that puts some data in a file
which works very well.
I want to instead of append to the file I want
to overwrite the contents of it.

??

-------------------existing code-------------------
<?php
$filename = "justatest.txt";
$output = "SOME_DATA_HERE";
$filehandle = fopen($filename, 'a');
fwrite($filehandle, $output);
fclose($filehandle);
?>


http://php.net/manual/en/function.fopen.php

"w" or "w+" istead of "a"
Jul 17 '05 #2
In comp.lang.php Jonny T <jo****@someisp3.com> wrote:
I want to instead of append to the file I want
to overwrite the contents of it. $filehandle = fopen($filename, 'a');


$filehandle = fopen($filename, 'w');

http://www.php.net/manual/en/function.fopen.php

--
niall
Jul 17 '05 #3
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 6 Apr 2004 10:10:37 +0000 (UTC)
Jonny T <jo****@someisp3.com> wrote:
<?php
$filename = "justatest.txt";
$output = "SOME_DATA_HERE";
$filehandle = fopen($filename, 'a');
fwrite($filehandle, $output);
fclose($filehandle);


Let the code look like this

$filename = "justatest.txt";
$output = "SOME_DATA_HERE";
$filehandle = fopen($filename, 'w');
fwrite($filehandle, $output);
fclose($filehandle);
- --
Kamratligen,
Davor
My GPG-key can be found at
http://blupp.net/~davor/davor.key
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQFAz5uNhCuya7YOfA4RAqFvAJ9e78B5F1RS9gV4D/EFjMHhCd5RNQCfWhTi
spKr4AfhBHf1D/JRKA1/Gc8=
=takd
-----END PGP SIGNATURE-----
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Gord | last post by:
Hello, If you set the flag for an overwrite prompt using the 'Save' common dialog, how do you read the response when the user clicks the Yes or No in the 'overwrite' message box? Everything...
5
by: Clint Stowers | last post by:
Access 2k Exporting a Query to as an excel file. No problem. However, I keep getting the warning that the file already exists, Overwrite Yes/No. Yes, I want to overwrite the file. ...
6
by: Tom | last post by:
I am having trouble when I read a file and another process is trying to update it. So I need a rountine to copy a file in asp.net. Can anyone assist? Thanks Tom
2
by: B-Dog | last post by:
Is there a way to make vb.net to overwrite the file when moving? Here is what I'm trying to do: If System.IO.File.Exists(dest) Then 'handle overwrite here If MessageBox.Show("Do you want...
8
by: Peter | last post by:
I'm trying to write a proceedure that will delete a file completely off a hardrive. I just don't want to kill the file. I want to rewrite over the data with 1's and 0's 8 times. Anyone have an...
3
by: Gene Vangampelaere | last post by:
Hi, I need to write a function that can replace some (.dll) files. That's easy to do but what if there are some files in use ? How can I replace those files ? is there a method to 'force' an...
26
by: Army1987 | last post by:
Is this a good way to check wheter a file already exists? #include <stdio.h> #include <stdlib.h> int ask(const char *prompt); typedef char filename; int main(int argc, char *argv) { FILE...
2
by: aigi | last post by:
hi! I have a question: How can I overwrite file on ftp server? I'm learning c# so please can U help me?
4
by: jcor | last post by:
Hi, I have a script that convert a file, "$novo" in this case, to a 3gp file: this is part of the script: print "qual é o título da peça? (< 36 caracteres)\n"; my $titul=<STDIN>;...
8
by: Joe Duchtel | last post by:
Hello - I have the following code to detemine a file name when my application is saving a file. The problem is that if the file already exists and I select the Yes button in the "Do you want to...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.