I have a big problem with displaying line breaks from mysql on my php generated html page. I tried the nl2br()manual str_replace()and so on ... In my sql database, the entry looks like this:
first line
second line
third line
BUT: There is no \nor in this entry <br>. If I get this data through an ajax call and using javascript: data.mystring.replace(/\n/g, "<br />")on it, everything works fine!
But now I have to send this data directly through php. And I do not see any gaps. It doesn't matter what I try. Any idea?
Here's the script (inserted via ajax call):
$adress = mysqli_real_escape_string($con, $_POST["adress"]);
mysqli_query($con, "INSERT INTO Contact SET Adress = '$adress');
Reading database data on my php page:
mysqli_query($con, "SET NAMES 'utf8'");
$query = mysqli_query($con, "SELECT * FROM Contact");
$dsatz = mysqli_fetch_assoc($query);
$newString = $dsatz["Adress"];
echo nl2br($newString);