New line Create in txt file use to file syntax

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Noorain
    New Member
    • Mar 2008
    • 57

    #1

    New line Create in txt file use to file syntax

    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_q uery($sql)or die(mysql_error ());
    $i=1;

    while($row=mysq l_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
    Last edited by Atli; Oct 22 '08, 11:25 AM. Reason: Added [code] tags.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    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

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Try changing that "\n" to "\r\n" instead.

      Comment

      Working...