note 85233 rejected from function.mysql-real-escape-string by mgf
| From: | mgf@php.net | Date: | Wed, 27 Aug 2008 12:00:42 +0000 |
| Subject: | note 85233 rejected from function.mysql-real-escape-string by mgf | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143867@lists.php.net to get a copy of this message | ||
Note Submitter: zareef at zareef dot net
----
mysql_real_escape_string function replace every new line and carriage return (Invisible \n and \r)
to literal \n and \r (visible). I think this must be documented.
For Example
[code]
mysql_connect("localhost","root","");
$FirstStr=<<< here
This is first line
This is second line
here;
$EscapedStr=mysql_real_escape_string($FirstStr);
print "Before :";
var_dump($FirstStr);
print "After :";
var_dump($EscapedStr);
[/code]
Output was :
Before :string(40) "This is first line This is second line " After :string(42) "This
is first line \nThis is second line\n"
I used str_replace to replace them with actual new line and carriage return characters.