Jump to content

edit forum post issue


EchoFool

Recommended Posts

When editing a forum post on my website i have the problem of seeing all the break links as <br> in the text area.

 

When i post a message i use nl2br() function so the structure remains when they post something but if they wish to edit it they will then see the all <br> in the text box whilst editing...

 

Is there a way to solve this issue so that they will see the structure and not all the <br> in the text box whilst they edit their post? How does phpfreaks do it ?

Link to comment
https://forums.phpfreaks.com/topic/202857-edit-forum-post-issue/
Share on other sites

You should not use nl2br on data BEFORE it goes into the database. You should enter the data into the database as RAW meaning with the \n characters. Before displaying the data on a page, you would use nl2br and if you are displaying it in a text area, do not use nl2br on it.

 

As it is I would suspect you are entering it into the database after running nl2br on the text, and thus the <br>'s are being entered into the DB instead of the new line characters, which, as you just found out can cause issues. If you are not doing it, then omit the nl2br on text data being put into a textarea.

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.