mysql_escape_string breaks EOL?
| From: | David Robley | Date: | Tue, 26 Oct 2004 09:34:11 +0000 |
| Subject: | mysql_escape_string breaks EOL? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-200329@lists.php.net to get a copy of this message | ||
It seems that mysql_escape_string and mysql_real_escape_string do
undesirable things to EOL markers - data from textareas escaped with either
of those functions is entered, and retrieved with, the characters /r/n
instead of a true line break.
This snippet of code demonstrates the problem:
<?php
$wibble = "\"This\" and\n'that'";
echo "Before: $wibble<BR>\n";
$wibble1 = addslashes($wibble);
echo "Addslashes: $wibble1<BR>\n";
$wibble2 = mysql_escape_string($wibble);
echo "Escape: $wibble2<BR>\n";
?>
And the output (from Show source) with line breaks exactly as in the source
Before: "This" and
'that'<BR>
Addslashes: \"This\" and
\'that\'<BR>
Escape: \"This\" and\n\'that\'<BR>
Is this a bug, or am I totally missing something?
Cheers
--
David Robley
Useless Invention: Avalanche prevention goggles.