Page 1 of 1

Line breaks, them evil line breaks!

Posted: Wed Dec 22, 2004 1:38 am
by pryj
Hi all,
I am running into a slight bit of a problem here. When an user uses textarea to enter data into MySQL, it stores the line breaks no problem. However, because of the way browsers render HTML, simply having them in there does not display them and I will probably need to convert them into
instead.

Is there any efficient way in doing this? Should I do that for every time something is pulled from the db? or should I do something prior to entering them into db? Any suggestions would be welcomed

Posted: Sun Mar 06, 2005 7:31 pm
by tanaka
Every line break goes to database as "\n". To display them when requesting data from db you can use the function nl2br

eg:
echo nl2br($form_text_area);