the problem:
I have 2 textareas, first one I use to send text to database (mysql) and the second is used to show the text retrieved. However, the line breaks from the first one aren't being applied to the second.
example:
hello
world
will appear like this:
hello world
when I checked the data I'm sending in the $_POST, I found that line break are being translated to this ' '
Array ( [memo_1] => fff ggg bbb )
and url encoded is like this:
memo_1: eee%E3%80%80ddd
other data removed from the array for the sake of brevity.
what I tried:
I tried to use nl2br, but since there are no \n in this text it doesnt work. I tried to use str_replace to change these characters to \n but also didn't work.
I'm not sure why are these weird characters are showing since I have the encoding set to UTF-8 and I'm sorry if this is not an encoding related problem.
update:
PHP: 5.6.38
mysql: 5.7.24 and the table collation is 'utf8_general_ci'
the project works inside a vagrant box: centos 6
saving:
include('./common/env.php');
include('./login_manager.php');
$virgin = $_POST['virgin'];
$memo_1 = $_POST['memo_1'];
$memo_2 = $_POST['memo_2'];
$call_counterpart = $_POST['call_counterpart'];
$call_status = $_POST['call_status'];
$recall_time_temp = $_POST['recall_time'];
$sql = "UPDATE call_history SET ";
$sql .= "memo_1 = '$memo_1', ";
$sql .= "memo_2 = '$memo_2', ";
$sql .= "call_status = '$call_status', ";
$sql .= "call_counterpart = '$call_counterpart', ";
if ($recall_time != "") {
$sql .= "recall_time = '$recall_time', ";
$sql .= "recall_flag = '1', ";
}
$sql .= "active_flag = '1' ";
$sql .= "WHERE id = '$history_id' ";
}
mysql_query($sql);`
retrieving:
$sql = "SELECT c.*, s.name staff_name ";
$sql .= "FROM call_history c ";
$sql .= "LEFT JOIN staff s ON c.staff_id = s.id ";
$sql .= "WHERE 1 ";
$sql .= "AND c.active_flag = 1 ";
$sql .= "ORDER BY c.id DESC ";
$rs = mysql_query($sql);