okrobie Posted May 1, 2010 Share Posted May 1, 2010 Hello, I am saving text to a MySQL database using a PHP form and I am formatting it using ordinary carriage return and line feeds. I am saving it to a longtext type but the text becomes concatenated stripping out the carriage return and line feeds. Is it possible to keep the formatting? Thanks, okrobie Quote Link to comment https://forums.phpfreaks.com/topic/200399-saving-formatted-text/ Share on other sites More sharing options...
premiso Posted May 1, 2010 Share Posted May 1, 2010 It is not stripping out the returns. On displaying the data from the database use nl2br and it will convert the returns to linebreaks. The reason for this is HTML does not display linebreaks, you have to use the html tag <br /> to get a line break to display, which nl2br does. Do not save it in your database with the <br /> tag. It is better to have data in it's raw form. Quote Link to comment https://forums.phpfreaks.com/topic/200399-saving-formatted-text/#findComment-1051645 Share on other sites More sharing options...
okrobie Posted May 1, 2010 Author Share Posted May 1, 2010 Thank you so much. It works like a charm. okrobie Quote Link to comment https://forums.phpfreaks.com/topic/200399-saving-formatted-text/#findComment-1051658 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.