DWilliams Posted February 19, 2010 Share Posted February 19, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/192674-text-from-database-output-without-newlines-thinking-its-a-unixwindows-issue/ Share on other sites More sharing options...
mikesta707 Posted February 19, 2010 Share Posted February 19, 2010 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); Quote Link to comment https://forums.phpfreaks.com/topic/192674-text-from-database-output-without-newlines-thinking-its-a-unixwindows-issue/#findComment-1015014 Share on other sites More sharing options...
DWilliams Posted February 19, 2010 Author Share Posted February 19, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/192674-text-from-database-output-without-newlines-thinking-its-a-unixwindows-issue/#findComment-1015018 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.