Well the escape is changing the singular character "\r" into two characters '\' and 'r'.
<?php
require_once 'default.inc.php';
$thestring = "This is\r\nthe string.";
$escape1 = mysql_real_escape_string($thestring);
$replace1 = str_replace(array("\n", "\r"), '', $escape1);
$replace2 = str_replace(array("\n", "\r"), '', $thestring);
$escape2 = mysql_real_escape_string($replace2);
echo '<pre>Before: ', str_hex($thestring), "\nEscaped1: ", str_hex($escape1), "\nReplace1: ", str_hex($replace1);
echo "\nReplace2: ", str_hex($thestring), "\nEscaped2: ", str_hex($escape2), "\n$escape2";
function str_hex($str)
{
$ret = '';
for($i=0, $n=strlen($str); $i < $n; $i++)
$ret .= sprintf('%02x', ord($str[$i])) . ' ';
return $ret;
}
output:
Before: 54 68 69 73 20 69 73 0d 0a 74 68 65 20 73 74 72 69 6e 67 2e
Escaped1: 54 68 69 73 20 69 73 5c 72 5c 6e 74 68 65 20 73 74 72 69 6e 67 2e
Replace1: 54 68 69 73 20 69 73 5c 72 5c 6e 74 68 65 20 73 74 72 69 6e 67 2e
Replace2: 54 68 69 73 20 69 73 0d 0a 74 68 65 20 73 74 72 69 6e 67 2e
Escaped2: 54 68 69 73 20 69 73 74 68 65 20 73 74 72 69 6e 67 2e
This isthe string.