473,225 Members | 1,318 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,225 software developers and data experts.

How to write string in a file to the next line

How to write data in a file to the next line

fwrite($ourFileHandle , $_POST[user]);
fwrite($ourFileHandle , "\n");
fwrite($ourFileHandle , $_POST[address]);

I want the following output

Peter
Main.st

How can i do that?
I tried many time,but Peter and main.st are on the same line.

Jul 17 '05 #1
4 15260
ma*****@hotmail.com wrote:
How to write data in a file to the next line

fwrite($ourFileHandle , $_POST[user]);
fwrite($ourFileHandle , "\n");
fwrite($ourFileHandle , $_POST[address]);

I want the following output

Peter
Main.st

How can i do that?
I tried many time,but Peter and main.st are on the same line.


\n only shows up in your browser when enclosed with <pre> tags.

Look at the source directly, use <pre> tags or use <br> instead of \n

JW

Jul 17 '05 #2
ma*****@hotmail.com wrote in news:1115044776.207438.318080
@o13g2000cwo.googlegroups.com:
How to write data in a file to the next line

fwrite($ourFileHandle , $_POST[user]);
fwrite($ourFileHandle , "\n");
fwrite($ourFileHandle , $_POST[address]);

I want the following output

Peter
Main.st

How can i do that?
I tried many time,but Peter and main.st are on the same line.


$user = trim($_POST['user']);
$add = trim($_POST['address']);

fwrite($ourFileHandle, "$user\n$add");

Jul 17 '05 #3
Good Man <he***@letsgo.com> wrote in news:Xns964A75DAB70FEsonicyouth@
216.196.97.131:
ma*****@hotmail.com wrote in news:1115044776.207438.318080
@o13g2000cwo.googlegroups.com:
How to write data in a file to the next line

fwrite($ourFileHandle , $_POST[user]);
fwrite($ourFileHandle , "\n");
fwrite($ourFileHandle , $_POST[address]);

I want the following output

Peter
Main.st

How can i do that?
I tried many time,but Peter and main.st are on the same line.


$user = trim($_POST['user']);
$add = trim($_POST['address']);

fwrite($ourFileHandle, "$user\n$add");


(assuming you were writing to a text file)
Jul 17 '05 #4
On Windows you need \r\n to produce a newline. Most editor is smart
enough to recognize \n, but not Notepad. You used to be able to open a
file in text mode, which turns on automatic translation of \n to \r\n.
But the PHP devs now are discouraging its use and, the last time I
tried, it didn't work.

Jul 17 '05 #5

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

Similar topics

2
by: lawrence | last post by:
I've been bad about documentation so far but I'm going to try to be better. I've mostly worked alone so I'm the only one, so far, who's suffered from my bad habits. But I'd like other programmers...
0
by: hari krishna | last post by:
hi all, My requirement is to generate xl reports throu Asp.Net without installing xl on web server computer. i am using Response object and wrtifile method as below. i dont know whether it is...
18
by: jas | last post by:
Hi, I would like to start a new process and be able to read/write from/to it. I have tried things like... import subprocess as sp p = sp.Popen("cmd.exe", stdout=sp.PIPE)...
1
by: D | last post by:
i have something where i am parsing information into a csv file with created headers. the script gets replayed as it tests several user profiles. how can i get it to continue writing on the last...
1
by: James | last post by:
vb.net 2003 - console program i've read a array of machines and i wishes to display on console the machines name on the *same line.* How do i do this ? This is what i want say i got a text...
13
by: Freaker85 | last post by:
Hello, I am new at programming in C and I am searching a manner to parse a string into an integer. I know how to do it in Java, but that doesn't work in C ;o) I searched the internet but I...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
24
by: Bill | last post by:
Hello, I'm trying to output buffer content to a file. I either get an access violation error, or crazy looking output in the file depending on which method I use to write the file. Can anyone...
6
by: globalrev | last post by:
i ahve a program that takes certain textsnippets out of one file and inserts them into another. problem is it jsut overwrites the first riow every time. i want to insert every new piece of...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.