Page 1 of 1

html special characters???

Posted: Wed Jan 22, 2003 5:35 am
by Skywalker
I am having some kind of guestbook, but when you are entering a text in an textarea and you give a enter je get an empty row in the textarea, but when you write it then to the database, the enter isn't enylonger ther

I just plases all of the text behind just as one blok not with seperated enters. How can I do this? A friend of mine told me to use special html characters, but how can I put them automatic in ther?

Greathings Skywalker

Posted: Wed Jan 22, 2003 5:41 am
by evilcoder
When your putting the message from the database into the page, assign it a variable then use this:

// Adds brake lines to html
$variable = nl2br( $variable );

Posted: Wed Jan 22, 2003 5:41 am
by twigletmac
Use nl2br() when you output the data. The newlines are not being lost when they go into the database, they are instead being stored as new line characters (\n), by using nl2br() on the text before you output it to the page you get an HTML line break (<br />) next to each newline character. This means that the text will look on the page as it does in the text area.

Mac

Posted: Wed Jan 22, 2003 5:42 am
by twigletmac
I appear to be getting slow in my old age :roll: .

Mac

Posted: Wed Jan 22, 2003 5:46 am
by evilcoder
hahaha, nah... Hey twig, are you good with Classes, Functions and Stupid Session that wont be cREATED I WORKED AGES ON THIS!!! LOL... sorry got a bit fired up?