Forum Moderators: coopster
I have a really simple question, bordering on stupid :)
When I take the input from a textarea and insert it into a mysql-base and then retrieve it and show it, all the line feeds/breaks are gone. It is shown as one giant string. How can this be fixed, so the text will be shown as it was entered? Does it have something to do with stripslashes/addslashes or am I way off?
Sorry for the dumb question, but for the life of me I can't remember or find out how this is done.
Thanks for any help...
If it's not this, you could be having problems with not escaping the input before it goes into the query. All input that goes into mysql queries should be escaped with mysql_real_escape_string().
Hope this helps.
here is a little addon:
A note to add to the br2nl. Since nl2br doesn't remove the line breaks when adding in the <br /> tags, it is necessary to strip those off before you convert all of the tags, otherwise you will get double spacing. Here is the modified function:function br2nl($str) {
$str = preg_replace("/(\r\nŠ\nŠ\r)/", "", $str);
return preg_replace("=<br */?>=i", "\n", $str);
}