View Single Post
Old 08-13-2002, 12:04 AM   PM User | #2
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
Hmmm... try this:

function cleanString($string)
{
$string = trim($string); // same as in asp
$string = htmlentities($string, ENT_QUOTES); // takes all the html tags and quotes and makes them specials chars
$string = addslashes($string); // adds slashes so it wont mess up php
$string = nl2br($string); // adds a <br> to all the returns that a user puts in a field
return($string);
}

Literally:

<%
Function CleanString(myString)
myString = Replace(myString,vbcrlf,"|~|")
myString = Replace(Server.HTMLEncode(Trim(myString)),"|~|","<br />")
CleanString = myString
End Function
%>

That's the quickest one I could come up with, anyway - someone might be able to make that 1 line instead of three...

P.S. the |~| is just some garbage combination I used that people most likely won't type in... you could use something else (unless I overlooked a way to do this easier, which is possible since I'm tired after auditioning for "Who wants to be a millionaire" at 7:00 this morning!).
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)

Last edited by whammy; 08-13-2002 at 12:27 AM..
whammy is offline   Reply With Quote