Jump to content

Text from database output without newlines, thinking it's a unix/windows issue


Recommended Posts

I'm trying to write a web report that pulls a block of text out of the database and displays it. Simple enough, right? Well, the data has been put there by a non-web desktop application running on Windows XP. It naturally includes line breaks for spacing purposes.

 

Now the database and webserver are on a server running Linux. When my report runs, it works correctly but the text field to be output is displayed all as one jumbled mess with no linebreaks. I know unix and windows have a fantastic battle going on over newline characters, and I'm assuming this has something to do with it. How can I display my text correctly?

 

And yes, the data is correctly stored with newlines. If I SSH into the server and fire up the mysql CLI client, I can select the data manually and it displays correctly.

if you are showing this data on a webpage (ie an HTML page) you want to change all the newlines to line breaks. the function nl2br() would work. example

echo nl2br($textWithNLs);

 

if you are showing this data on a webpage (ie an HTML page) you want to change all the newlines to line breaks. the function nl2br() would work. example

echo nl2br($textWithNLs);

 

That works beautifully, thanks!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.