Solved

Writing line breaks to text file - getting little squares

Posted on 2004-04-27
8
401 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:Reapz
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

757 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now