Writing line breaks to text file - getting little squares

Posted on 2004-04-27
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:

  $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?
Question by:earthman100

Expert Comment

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".
LVL 32

Expert Comment

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...

Author Comment

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.
Industry Leaders: 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!


Author Comment

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

Author Comment

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:

Thanks y'all anyhoo.

Accepted Solution

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

Expert Comment

ID: 21931220
I had the same issue,

the suggestion above,

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



Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PHP 5.6 and 7.x 4 37
EditableGrid how to fetch rows from MySql in php 14 44
How to use session variables in php? 22 41
MySQL-Design Help 12 38
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
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 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 …

679 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