textarea problem..help please

windows

Guest
hi everybody, can someone help with this?<br />
i have a form with a textarea item, after inserting the <br />
text i keep it in a database(mysql), but when retriving the<br />
text from the db, it doesn't look good.<br />
Example:<br />
I insert this : this is in line1(return)<br />
this is line2(return)<br />
this is line3(return).<br />
<br />
When i look into the db, it stays good, when retriving it stays like this: this is line1 this is line2 this is line3, what is very nasty.<br />
<br />
Thanks.<!--content-->because you need to replace al the <br> into \n so the textare can read those line breaks<!--content-->I don't know what scripting language you are using to retreive the information but in php you would use this for auto line breaks:<br />
<br />
$text = nl2br($text); <br />
<br />
:)<!--content-->Originally posted by scoutt <br />
because you need to replace al the <br> into \n so the textare can read those line breaks <br />
<br />
Did you mean the reverse? Replace \n with <BR>.<!--content-->actyually nope. if it goes back into the textarea it would be back to \n.<br />
<br />
when they submit it goes form \n to <br> so it goes into the webpage ok, then if they edit it then it would be <be> to \n so it gets spaced in the textarea correctly.<br />
<br />
or what Mr Tech suggested :)<!--content-->Well in ASP I use this function to replace all special characters:<br />
<br />
<br />
<%<br />
Function Escape(sString)<br />
<br />
'Replace any Cr and Lf to <br><br />
strReturn = Replace(sString , vbCrLf, "<br>") : 'visual basic carriage return line feed ***********\<br />
strReturn = Replace(strReturn , vbCr , "<br>") : 'visual basic carriage return *********These 3 are line breaks hence <BR><br />
strReturn = Replace(strReturn , vbLf , "<br>") : 'visual basic line feed ***********/<br />
strReturn = Replace(strReturn, "'", "''") : 'Single quote changed to 2 single quotes ASP knows what to do<br />
Escape = strReturn<br />
End Function<br />
%><br />
<br />
<%<br />
rProb=Escape(rProb)<br />
%><br />
<br />
<br />
The textarea contents are stored in the database and then pulled out and stored as the variable called rProb. Use the Escape function on rProb before you display it.<!--content-->hi..thanks for the answers, i have manage the problem.<br />
thanks again.<!--content-->
 
Back
Top