Dealing with \n\r

Report
Posts
1010
Registration date
Saturday January 17, 2015
Status
Moderator
Last seen
June 16, 2020
-
Hi All,

I have another problem ... just as things were going well :^(

I have a web site that allows a free text input which gets sanitised and subsequently added to a MySQL database. The sanitisation process is by :
$problem_description = mysqli_real_escape_string($conn, $_POST['problem_description']);


It is then inserted into the database with:
$insert_data = $conn->prepare("INSERT INTO raw_data (Contact_Name,  Problem_Description) VALUES (?, ?)");
$insert_data->bind_param("ss", $contact, $description);

$contact = $contact_name;
$description = $problem_description;


When it is retrieved if the user has entered line breaks by pressing the enter key it gives:

text block 1\n\rtext block 2

instead of

text block 1
text block 2


The retrieval process is:

<?php
$data = "SELECT * FROM raw_data WHERE id='$ticket_number'";
$result = mysqli_query($conn, $data);
$value = mysqli_fetch_array($result);
?>

<textarea id='edit_problem_description' name='problem_description' required readonly="readonly"><?php echo $value['Problem_Description']?></textarea>


How do I make the text show as required please?

I have scoured the internet and nothing I try seems to help. With this in mind I have doubled the usual reward - I have 2 virtual nights out on the town to offer, but they cant be taken until the world is free of this nasty COVID-19 virus.