473,326 Members | 2,813 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,326 software developers and data experts.

adding a new line character in a string.

Hi friends

I need to write s string into a log file a string each time I run my php script.

How could I write the details into a new line each time I run.

I tried using \n but it is not working.....
eg:
$logdetail= "date: ".$todate.$count."values inserted\n";
fwrite($fptr, $logdetail);

THIS IS VERY URGENT Friends
Feb 1 '07 #1
3 12728
Motoma
3,237 Expert 2GB
Hi friends

I need to write s string into a log file a string each time I run my php script.

How could I write the details into a new line each time I run.

I tried using \n but it is not working.....
eg:
$logdetail= "date: ".$todate.$count."values inserted\n";
fwrite($fptr, $logdetail);

THIS IS VERY URGENT Friends
Welcome to The Scripts!
Did you use fopen()?
Feb 1 '07 #2
Atli
5,058 Expert 4TB
Hi.

If your using windows you should do "\r\n" instead of "\n".

[PHP]$fh = fopen($filename, "a");
fwrite("I am a new line :D \r\n");
fclose($fh);[/PHP]
Feb 1 '07 #3
for adding a new line caharacter in a string, concatenate the string with a \n enclosed in double quotes.
eg: $string="new employee"."\n";
fwrite($fptr, $string);
This will write the contents of the string '$string' in to the file and take the cursor to the next line of the file.
So, when you execute the foll: code,
$emp_name="John";
fwrite($fptr, $emp_name);
The name John will be printed in the next line of the file.

i.e. new employee
John
Feb 6 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Nikita A. Visnevski | last post by:
Hi everyone, I am rather new to Java beans. Just picked up a book last night and started reading about them. I am building an application that allows a user to define objects with dynamic...
6
by: DLP22192 | last post by:
I have the following single-line if statement that is evaluating true even though it shouldn't. I have never seen this before and I am concerned that this can happen in other areas of my code. ...
4
by: Surya Kiran | last post by:
Hi all, I'm facing a wierd problem. I've a file, which is getting updated every now and then. and i'm having another program, which monitors the file. I've to read the file line by line, and in...
4
by: Steve Smith | last post by:
I need to add an additional String parameter to a Java SP (DB2 8.1 0 using DB2 Development Center - FP4). Everytime I do this I get the following error message when building:-...
23
by: FrancisC | last post by:
#include <stdio.h> int file_copy( char *oldname, char *newname ); int main() { char source, destination; printf("\nEnter source file: ");
8
by: Dawn Minnis | last post by:
Hey guys If I have a program (see codeSnippet1) that I compile to be called test.o Then run it as test.o n n 2 3 4 I want the code to be able to strip out the two characters at the start...
9
by: Jonny | last post by:
Hi, Please could you tell me what the quickest way would be to verify that a line of text exists in a file. I would like to be able to do something like: grep "^line of text$" filename.txt...
6
by: charliewest | last post by:
Hi. I've a rather newbie question: I'm concatenating several strings, adding "\n" where necessary, and setting the final string to the text property of a multi-line textBox control. However,...
20
by: plmanikandan | last post by:
Hi, I need to read a file line by line.each line contains different number of characters.I opened file using fopen function.is there any function to read the file line by line Regards, Mani
6
by: Paulers | last post by:
Hello, I have a string that I am trying to add each char to a datatable row. for example if I have a string that looks like "abcdefg", I would like to break it up into an array of characters...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.