I want to insert a similar string into DB, but after inserting the characters "\n" disappear and in DB I see it as new line.
The string which I send:
[{"Index":0,"Title":"headline","Content":"first line\nsecond line","Class":"colour1"}]
For insert to DB, I use this PHP code and string I send via HTML form with method POST.
if ( $action == "save") {
$notes = $_POST['notes'];
$sql = "INSERT INTO notes (notes) VALUES ('$notes')";
if (mysqli_query($conn, $sql)) {
$saved = "Saved...";
} else {
$saved = "Error: " . mysqli_error($conn);
}
}
When I print variable "$_POST['notes']" or "$notes" before sending via the form, the string is OK, after sending the form and before inserting into DB, the string is OK too.