If I use mysql_real_escape_string on it, it no longer shows me line breaks.
Can't you see "\n" literals instead of line breaks?
if so, your code does some unpleasant things, most likely you are avoiding the data twice.
or, you do not do mysql_real_escape_string () after retrieving data from the database?
In any case, you need to do some debugging - an investigation to find out what happens to your data at each stage . Just print out $ _POST ['textarea_name'], SQL query, etc.
To see the moment when you lose your breaks and recognize the criminal
Notes:
mysql_real_escape_string does not protect anything from any attack. This eludes the delimiters.
nl2br does not save anything. It adds an HTML tag to line breaks.
source share