Forum Moderators: coopster

Message Too Old, No Replies

Textarea rows disappear when the input is retrieved from database

         

Gero_Master

12:20 pm on Jan 8, 2006 (gmt 0)

10+ Year Member



Hello!

The problem is that when i make a textarea, which saves the data to database, the user added rows (presses of 'enter') wont show up.

Example:
Textarea:
hello!

My name is tomi

On the site retrieved from database:
Hello!My name is tomi

jc_armor

1:59 pm on Jan 8, 2006 (gmt 0)

10+ Year Member



just use nl2br so that you can view the new lines. ex:

echo nl2br($mrow["text"]);

inveni0

2:30 pm on Jan 8, 2006 (gmt 0)

10+ Year Member



You'll also probably have the problem of <br /> showing up should you want to edit the entry in a text area. So, use:

striptags($row_Row['Column'], '<br />');

For adding those tags as you asked before, I just place $textarea = nl2br($textarea); at the end of the edit form action area. Then, in my sprintf statement, instead of using:

GetSQLValueString($_POST['textarea']);

I use:

GetSQLValueString($textarea);

Gero_Master

3:05 pm on Jan 8, 2006 (gmt 0)

10+ Year Member



I don't think <br> and <br/> tags will be a problem, since I have enabled a thing that will erase all javascript & html which users are trying to feed in my database.

Thanks rof both of you for your replies, this will most certainly be a day savier for me :)

Tomi

inveni0

8:25 pm on Jan 8, 2006 (gmt 0)

10+ Year Member



The <br> tag is how the code interprets the carriage returns.

Gero_Master

10:16 am on Jan 22, 2006 (gmt 0)

10+ Year Member



I'm having a problem... I noticed, when I use that nb2bl function, it only shows 1 row change.

If i write:

Hello!

Tomi

It appears as:

Hello!
Tomi

inveni0

2:54 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



nl2br should do both. Are you sure you're using the right command?

Gero_Master

3:30 pm on Jan 22, 2006 (gmt 0)

10+ Year Member



im using it like this:

echo nl2br($themessage_message) ;