Re: mysql_escape_string breaks EOL?

From: Date: Wed, 27 Oct 2004 00:46:46 +0000
Subject: Re: mysql_escape_string breaks EOL?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200390@lists.php.net to get a copy of this message
David Robley wrote:
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?
No, it's not a bug. If you use it in mysql query, mysql server will convert \n to newline character

« previous php.general (#200390) next »