Page 1 of 1

enter in textarea problem

Posted: Tue Mar 16, 2004 11:55 pm
by potato
I have a textarea where i would enter a description.
But my problemisthat if i 'enter' in the textarea, i doesn't save the enter
in my mysql tabel.
How can i fix that?

Posted: Tue Mar 16, 2004 11:59 pm
by andre_c
you should use the nl2br() function. Look it up in php.net

Posted: Wed Mar 17, 2004 12:06 am
by Goowe
Another way...

function convertReturns($input_text) {
$input_text = ereg_replace("\n","<BR>",$input_text);
return $input_text;
}

Then when you're displaying something from the mySQL database that needs to be returned and has those return line thinger majigs just do something like

convertReturns($row['news_article']);

Posted: Wed Mar 17, 2004 12:09 am
by andre_c
...that does the same as nl2br() only that nl2br() is xhtml compliant, replacing "\n" with "<br />\n". In my opinion it's more efficient to use predefined functions when they exist.

Posted: Wed Mar 17, 2004 12:12 am
by Goowe
Sorry

Posted: Wed Mar 17, 2004 12:14 am
by andre_c
:) I wrote great number of functions when I first started programming before realizing that there were predefined functions that did the same thing

Posted: Wed Mar 17, 2004 1:44 am
by m3mn0n
andre_c wrote::) I wrote great number of functions when I first started programming before realizing that there were predefined functions that did the same thing
lol Me too! :wink:

Posted: Wed Mar 17, 2004 7:40 am
by potato
i'm sorry, but where do i have to write this?
More information if it is possible.
Newbie, you now. :oops:

Posted: Wed Mar 17, 2004 1:06 pm
by andre_c
You can either use the function before you send to the database or after you retrieve it:

Code: Select all

$text = nl2br($text);

Posted: Wed Mar 17, 2004 2:47 pm
by potato
Thanx