Jump to content

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


DWilliams

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);

 

That works beautifully, thanks!

Archived

This topic is now archived and is closed to further replies.

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