PHP CRLF write to file from MySQL?

Get help on web editors (Frontpage, Dreamweaver) and web languages (HTML, ASP, PHP).
Post Reply
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

PHP CRLF write to file from MySQL?

Post by SBSP »

I have a MySQL database which i can read from using some basic PHP code.

I read the data from the MySQL tables into string then i want to write the data to file.

I found this tutorial

Code: Select all

<?php


echo "test";


$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "Bobby Bopper\n";
fwrite($fh, $stringData);
$stringData = "Tracy Tanner\n";
fwrite($fh, $stringData);
fclose($fh);

?>
this basically writes the words Bobby Bopper [\n] Tracy Tanner\n to file whats the \n for ?
i assume its supposed to write CRLF for the line return but if i open it in word or notepad it
shows a block.

I think depending what character system you use to open it with it will return the line ? am i right ?
User avatar
rustypup
Registered User
Posts: 8872
Joined: 13 Dec 2004, 02:00
Location: nullus pixius demonica
Contact:

Re: PHP CRLF write to file from MySQL?

Post by rustypup »

it's system dependant... if you want to be sure not to have hiccups, \r\n is probably better...
Most people would sooner die than think; in fact, they do so - Bertrand Russel
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Re: PHP CRLF write to file from MySQL?

Post by SBSP »

Thanks
Post Reply