I created a function that checks if value in database is the same as value from submitted form. The function has to compare both data and update only if they are different, but doesn't work properly. $value
comes from $_POST
textarea:
$value = mysql_real_escape_string($value);
$result = mysql_query("SELECT info FROM database1 WHERE id=1 "); $row = mysql_fetch_row($result);
if ($value == $row[0]) echo "The same!";
else echo "They are different!";
The problem is about line breaks. Data from database in html source view looks like that:
line1
line2
Data from POST in html source view:
line1\r\nline2
So when I compare these both it's different, but in fact they are the same from database point of view. I tried $value = str_replace('\r\n','', $value);
and $value = str_replace('\r\n','<br>', $value);
for data from POST and it doesn't help. Maybe I should replace \r\n
into something different, but for what?