phpSensei Posted August 24, 2007 Share Posted August 24, 2007 How do you make it so when a user posts a comment, and presses enter for a new line, that the white space between the paragraph turns into a <br>. Or This Is A problem with htmlentites to prevent XSS, I am clueless. Quote Link to comment https://forums.phpfreaks.com/topic/66421-solved-preg-match-problem/ Share on other sites More sharing options...
trq Posted August 24, 2007 Share Posted August 24, 2007 Turns into a what? Use code tags so we can see whats going on. Maybe its nl2br your looking for. Quote Link to comment https://forums.phpfreaks.com/topic/66421-solved-preg-match-problem/#findComment-332465 Share on other sites More sharing options...
phpSensei Posted August 24, 2007 Author Share Posted August 24, 2007 Trouble is, When you insert a normal text area on your page and you type in something like text: "TextTextTextTextTextTextTextTextTextTextTextTextTextTextText TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText TextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextTextText TextTextTextTextTextTextTextTextTextTextTextTextText TextTextTextTextTextTextTextTextTextTextTextTextTextTextText" You can the line break between paragraph one and paragraph two, but when you put this data into your mysql database, that break is gone. Therefor the text would be stuck together... How do you make it so it turns that empty space into a <br> or New line Quote Link to comment https://forums.phpfreaks.com/topic/66421-solved-preg-match-problem/#findComment-332545 Share on other sites More sharing options...
hitman6003 Posted August 24, 2007 Share Posted August 24, 2007 Maybe its nl2br your looking for. Quote Link to comment https://forums.phpfreaks.com/topic/66421-solved-preg-match-problem/#findComment-332547 Share on other sites More sharing options...
MadTechie Posted August 24, 2007 Share Posted August 24, 2007 try $string= nl2br($string); EDIT: Quote Link to comment https://forums.phpfreaks.com/topic/66421-solved-preg-match-problem/#findComment-332549 Share on other sites More sharing options...
trq Posted August 24, 2007 Share Posted August 24, 2007 When you retrieve the data back out for display use nl2br() on it. Quote Link to comment https://forums.phpfreaks.com/topic/66421-solved-preg-match-problem/#findComment-332551 Share on other sites More sharing options...
hitman6003 Posted August 24, 2007 Share Posted August 24, 2007 I think we should all recommend nl2br again. Also, br2nl isn't a (predefined/builtin) function Quote Link to comment https://forums.phpfreaks.com/topic/66421-solved-preg-match-problem/#findComment-332557 Share on other sites More sharing options...
MadTechie Posted August 24, 2007 Share Posted August 24, 2007 Yeah, remembed that after i hit post LOL.. Quote Link to comment https://forums.phpfreaks.com/topic/66421-solved-preg-match-problem/#findComment-332561 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.