Forum Moderators: coopster

Message Too Old, No Replies

textarea formatting errors

         

panoz

1:01 pm on Jan 3, 2004 (gmt 0)

10+ Year Member



Hey guys.

Been using the nl2br() to format the text that is inserted into a textarea and then sent to mysql. But two different problems have occured now..

First one:
Once I edit the text in the textarea and send it, it looks fine. But when I have to alter it again the <br /> tags are shown and they should appear I guess. But when the text is sent into mysql database once more the <br /> tags are twice as many. And the formatting is screwed up. Is there any way to get rid of it? Below is the code that I use for the sql query.

-----------------
// Update the following parts in the info table from the values that are sent from update_info.php form

$query="UPDATE info SET infotext='".$_POST['text_info']."', rubrik='".$_POST['rubr_info']."';";
mysql_query(nl2br($query));
-----------------

Second one:
Is it possible to not show the <br /> tags in the textarea?

henry0

1:33 pm on Jan 3, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



did you look at that and users comments
[us2.php.net...]

panoz

2:19 pm on Jan 3, 2004 (gmt 0)

10+ Year Member



Nope man.. but they didn't make me sooo damn smarter! :D

With some(much) help I managed to find out that the following code does the trick:
$content = str_replace("<br />", "", $content);

cheers!