Home > Article > Backend Development > Found a weird bug and don’t know how to solve it_PHP Tutorial
In textarea, rn is used for line breaks (the same is true for ckeditor), but str_replace() cannot be used to process rn. I don’t know why.
// Line breaks in textarea use rn, and they cannot be removed using the str_replace method! !
//The test1 table has only two fields, id and textarea, and only one record with id=1.
require_once 'connect_text.php';
require_once 'show_message.php';
if($_POST['text']){
$text = str_replace('rn', '', $ _POST['text']); //Tried to remove it, but the test result was not removed rn
$query="UPDATE test1 SET textarea = '$text' WHERE id = '1'";
$result = mysql_query($query);
if($result){
echo "<script>alert('It's done!')</script>";
}
}
$query = "SELECT textarea FROM test1 WHERE id = '1'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
?> ;