Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Writing line breaks to text file - getting little squares

Posted on 2004-04-27
8
Medium Priority
?
412 Views
Last Modified: 2013-12-12
Hi, I am using the script:

$inputString = "Customer\tContact\tStreet\tCity\tProvince\tPostal code\tPhone\tFax\tE-mail\tWeb site\tMemo\n";
$fp = fopen("SAtemp/temp.txt", "w+") or die("Couldn't create new file");
fwrite( $fp, $inputString );

to write text to a file, then to send it by email I use:

 include('class.Email.php');   //this class is found at: http://codewalkers.com/seecode/430.html

  $NewEmail = new Email($compName." <".$rcpemail.">", $email, $subject);
  $NewEmail->TextOnly = true;
  $NewEmail->Content = "This email has been sent to you through the ". $compName." Contact form at ".$compURL."\r\n\r\nMessage from: ".$customer."\r\nReply email address: ".$email."\r\n Website address: ".$website."\r\nContact Name: ".$contact."\r\nAddress: ".$street."\r\nCity: ".$city."\r\nProvince: ".$province."\r\nPostal Code: ".$postalcode."\r\nPhone Number: ".$phone."\r\nFax Number: ".$fax."\r\n\r\n=================== Message Text Below ====================\n\n".stripslashes($memo);

//** send a copy of this file in the email.

  $NewEmail->Attach("SAtemp/temp.txt", "text/plain");


Now, the only problem I have is when I open the text file I see a little square at the end of the line instead of the line break.  Any suggestions, please?
0
Comment
Question by:earthman100
8 Comments
 
LVL 6

Expert Comment

by:Andy
ID: 10934619
Are you getting...

some stuff here[]some more stuff[]and yet another line

Or are you getting...

some stuff here[]
some more stuff[]
and yet another line

If it's the second one try removing all the instances of \r and just leave the \n's in.

Alternatively, try replacing "text/plain" with "text/html".
0
 
LVL 32

Expert Comment

by:ldbkutty
ID: 10935566
You can try using Ln() Line break functio, instead...

$NewEmail->Content = "This email has been sent to you through the ". $compName." Contact form at ".$compURL.Ln().Ln()."Message from: ".$customer.Ln()."\rReply email address: ".$email.Ln()." Website address: ".$website.Ln()."Contact Name: ".$contact.Ln()."Address: ".$street.Ln()."City: "................and so on....

If i was wrong somewhere, you can well see and use this tutorial...

http://www.id.unizh.ch/publications/fpdf/doc/ln.htm
0
 

Author Comment

by:earthman100
ID: 10935717
Actually I am getting it in the text file I am generating:

$inputString = "Customer\tContact\tStreet\tCity\tProvince\tPostal code\tPhone\tFax\tE-mail\tWeb site\tMemo\n";

at the end.  Just a single square, with no line break.  The others work fine.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:earthman100
ID: 10935875
I tried text/html and still get the same result in the txt file.  Any further suggestions would be appreciated!  Thanks!
0
 

Author Comment

by:earthman100
ID: 10935911
ooop, I got it.  I had tried \n\r and it didn't work, but then I discovered I needed to put \r\n instead.  YAY!

found it at: http://forums.devshed.com/archive/t-26036

Thanks y'all anyhoo.
0
 

Accepted Solution

by:
PashaMod earned 0 total points
ID: 10971691
Closed, 500 points refunded.
PashaMod
Community Support Moderator
0
 
LVL 3

Expert Comment

by:homemadebyx
ID: 21931220
I had the same issue,

the suggestion above,

(ID:10935911  Author:earthman100  Date:04.27.2004 at 11:13PM PDTAuthor Comment)

worked.


X
homemadebyx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question