By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,889 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,889 IT Pros & Developers. It's quick & easy.

New line Create in txt file use to file syntax

P: 57
Sir

I create a file and all date save in txt file. i need 2nd data show in next line or line break but line break doesn't work in txt Format. please help me.
[PHP]<?
$myFile = "test.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$sl=1;
$Cur_Trns_Dt = date('Y-m-d');
?>
<?
$br = "\n";

$spr = ";";
$sql = "SELECT * FROM `stu_info` WHERE age=25 ORDER BY id ASC";
$result=mysql_query($sql)or die(mysql_error());
$i=1;

while($row=mysql_fetch_array($result))
{

$id=$row['id'];
$Name=$row['name'];
$Age=$row['age'];
$Address=$row['address'];

//WRITE DATA
fwrite($fh, $id);
fwrite($fh, $spr);
fwrite($fh, $Name);
fwrite($fh, $spr);
fwrite($fh, $Age);
fwrite($fh, $spr);
fwrite($fh, $Address);
fwrite($fh, $br);

$i++;
}
?>
<?
fclose($fh);
?>[/PHP]
Thanks Noorain
Oct 22 '08 #1
Share this Question
Share on Google+
2 Replies


Atli
Expert 5K+
P: 5,058
Noorain.

You have been asked several times before by several moderators to use [code] tags when posting your code examples, yet you continue to ignore us.

Now I am telling you; use [code] tags when posting your code examples or you will find yourself banned from these forums.
I will not ask you again.

Thank you.
Moderator
Oct 22 '08 #2

10K+
P: 13,264
Try changing that "\n" to "\r\n" instead.
Oct 22 '08 #3

Post your reply

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