Jump to content

[SOLVED] post text looses line breaks


tidus97

Recommended Posts

hey guys. i posted about filtering out text and making it safe for input before and came up with this:

function cleanupForStorage($x,$inExep=null){
$x = mysql_real_escape_string($x);
$x = strip_tags($x,$inExep);
return $x;
}

function cleanupForOutput($x,$exep=null){
$order   = array('\r\n' , '\n', '\r');
$x = str_replace($order, '<br />', $x);
$x = stripslashes($x);
return $x;
}





$string = '<b>Hello, World!</b>""""""" do <i>you</i> like\hate slashes? and these "quotes"?
what
about
new
lines';

$string=cleanupForStorage($string,'<b>');
echo "This is for storage: ".$string."<br />";

$string=cleanupForOutput($string);
echo "This is for output: ".$string."<br />";

 

what i do to put text into a DB is use a form to post it over to another php file that does the job. but for some reason, when i use the clean up for storage function, breaks are replaced by spaces and not '\r\n' , '\n' or '\r' and so i cant turn them into <br />'s. its not the functions, because i echo the posted text right away in the next php fle and the line breaks are gone.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.