cooldude832 Posted October 31, 2007 Share Posted October 31, 2007 I tried doind a nl2br() on my textarea, but the spacing failed to work any idea maybe a str_replace("\r","<br />",$string); ?? Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 31, 2007 Share Posted October 31, 2007 can you explain it a little bit more Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted October 31, 2007 Author Share Posted October 31, 2007 when you type in a textarea like posting message, I want the spaces to be relavent as they are here in my example of typing in this $bio = mysql_real_escape_string(bb2html((stripslashes(strip_tags(trim($_POST['Bio']))))); they aren't relative Quote Link to comment Share on other sites More sharing options...
trq Posted October 31, 2007 Share Posted October 31, 2007 Simply use nl2br when you display the data. Not on the way in to the database. Quote Link to comment Share on other sites More sharing options...
hitman6003 Posted October 31, 2007 Share Posted October 31, 2007 If you want to preserve the spacing at the beginning of a line, you'll have to wrap the string in pre tags, or replace the spaces with ... $string = "this is a string with random spacing"; echo "This is the unadulterated string: <br />" . $string . "<br /><br />"; echo "This is the string with pre tags:<pre>" . $string . "</pre><br /><br />""; echo "This is the string without pre tags, but with formatting: " . nl2br(str_replace(" ", " ", $string)); Remember that unless you use a monospace font (e.g. Courier New) the characters won't line up. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted October 31, 2007 Author Share Posted October 31, 2007 Simply use nl2br when you display the data. Not on the way in to the database. I did this on the output no good my input looks line Line 1 Some stuff..... Line2 Some stuff.... Line 3 Some stuff. But on output using $bio = nl2br($row['Bio']); echo $bio; it is Line 1 Some stuff.....Line2 Some stuff....Line 3 Some stuff. I use $bio = mysql_real_escape_string(bb2html(stripslashes(strip_tags(trim($_POST['Bio']))))); on it going in, and coming back into the <textarea> it looks fine with the breaklines, but outputted no. So I know my bbcode ain't kill it. Quote Link to comment Share on other sites More sharing options...
teng84 Posted October 31, 2007 Share Posted October 31, 2007 but outputted no. So I know my bbcode ain't kill it. it ain't kill your nl2br but ? then i guess that is not working try to replace bb2html with nl2br AND surely it will work Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted October 31, 2007 Author Share Posted October 31, 2007 I hadn't verified any of the data and what I found out through looking closer was that data had some funky spacing to it. so it really wasn't a line break in it, but actually some idiot holding down the space bar. I think what was happening was the browsers were not reading the extra spaces and thus decided to nuke em out. So now I got 150 profiles to sanitize fun However I will note I tested some returns and the nl2br() on output worked fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.