Jump to content

Saving formatted text


okrobie

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/200399-saving-formatted-text/
Share on other sites

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.

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.