I run all my POST data through a cleaner to escape it and to fix the line breaks
function cleanCode($dirty) {
$clean = str_replace( "\n", "<br />", $dirty);
$clean = mysql_real_escape_string($clean);
return $clean;
}
$_POST['data'] = cleanCode($_POST['data']);
than if you're editing the data from the database you can use str_replace( "<br />", "\n", $string); to edit it