473,793 Members | 2,865 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write string in a file to the next line

How to write data in a file to the next line

fwrite($ourFile Handle , $_POST[user]);
fwrite($ourFile Handle , "\n");
fwrite($ourFile Handle , $_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 15287
ma*****@hotmail .com wrote:
How to write data in a file to the next line

fwrite($ourFile Handle , $_POST[user]);
fwrite($ourFile Handle , "\n");
fwrite($ourFile Handle , $_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.go oglegroups.com:
How to write data in a file to the next line

fwrite($ourFile Handle , $_POST[user]);
fwrite($ourFile Handle , "\n");
fwrite($ourFile Handle , $_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($ourFile Handle, "$user\n$ad d");

Jul 17 '05 #3
Good Man <he***@letsgo.c om> wrote in news:Xns964A75D AB70FEsonicyout h@
216.196.97.131:
ma*****@hotmail .com wrote in news:1115044776 .207438.318080
@o13g2000cwo.go oglegroups.com:
How to write data in a file to the next line

fwrite($ourFile Handle , $_POST[user]);
fwrite($ourFile Handle , "\n");
fwrite($ourFile Handle , $_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($ourFile Handle, "$user\n$ad d");


(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
3058
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 to have an easier time understanding what I do. Therefore this weekend I'm going to spend 3 days just writing comments. Before I do it, I thought I'd ask other programmers what information they find useful. Below is a typical class I've...
0
1763
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 correct, but giving error says " file is accessed by other process cannot access" I have some logic inbetween and write the info using response.write in to html format Ex: Response.Write("<td>" & "client_no" & "</td>"). I am getting the error at :...
18
4894
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) p.stdin.write("hostname\n") however, it doesn't seem to work. I think the cmd.exe is catching it.
1
7559
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 line (and not rewrite over info.) of the file where it left off? on another note, how to get rid of extra quotes in the csv file output? vb.net 2003 doesnt like when i take them off or add on more.
1
2505
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 file that contains machine001 machine002 it shld display in console as
13
3227
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 didn't found it yet. help please thank you Freaker85
0
789
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 by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
3
14059
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 by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
24
4458
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 help out a newbie? #include <stdio.h> #include <ctype.h> #include <string.h>
6
18305
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 text into the next row. so: 1. how do i write to a new line every time i write to the file? 2. if i dont want to write to a new line but just want to insert it
0
9671
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10212
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9035
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6777
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4112
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2919
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.