EchoFool Posted May 25, 2010 Share Posted May 25, 2010 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 ? Quote Link to comment https://forums.phpfreaks.com/topic/202857-edit-forum-post-issue/ Share on other sites More sharing options...
premiso Posted May 25, 2010 Share Posted May 25, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/202857-edit-forum-post-issue/#findComment-1063106 Share on other sites More sharing options...
EchoFool Posted May 25, 2010 Author Share Posted May 25, 2010 Oh thats where im going wrong then IS it /n/n or just /n? Quote Link to comment https://forums.phpfreaks.com/topic/202857-edit-forum-post-issue/#findComment-1063110 Share on other sites More sharing options...
premiso Posted May 25, 2010 Share Posted May 25, 2010 Neither. \n is generally what is a newline character is. Quote Link to comment https://forums.phpfreaks.com/topic/202857-edit-forum-post-issue/#findComment-1063111 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.