Double Mysql_real_escape_string Insert Of New Line Characters. How To Get New Line Breaks Back?
I have a textarea field that's inserted into a mysql database which may contain line breaks. The textarea data has accidentally gone through two lots of mysql_real_escape_string fu
Solution 1:
You are probably do escaping using mysql_real_escape string twice - as input filter (wrong!) and as a SQL data preparation. You have to get rid of the first one.
Or once, as input filter, and then use prepared statements for the query. Get rid of the first one as well.
Solution 2:
You should definitely fix the situation that is leading to the double escaping.
A quick fix for contents already processed that way is
str_replace("\\r\\n", "\r\n");
Solution 3:
To get your original back, you have to do the reverse. Make a script that selects your existing rows from the table, and without escaping the input, update the column value. This, in essence, will store back in the single (correctly) escaped input.
Solution 4:
Try This Code
$tval= str_replace("\\r\\n", "\r\n",mysql_real_escape_string(trim($tval)));
Post a Comment for "Double Mysql_real_escape_string Insert Of New Line Characters. How To Get New Line Breaks Back?"