Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Writing line breaks to text file - getting little squares

Posted on 2004-04-27
8
Medium Priority
?
411 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

661 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