note 104354 deleted from function.mysql-real-escape-string by danbrown
| From: | danbrown@php.net | Date: | Fri, 10 Jun 2011 15:27:37 +0000 |
| Subject: | note 104354 deleted from function.mysql-real-escape-string by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180415@lists.php.net to get a copy of this message | ||
Note Submitter: alsuara at gmail dot com
----
a detail to be added to the function reverse_escape of m-t at live dot fr (17-Oct-2010 04:30)
I used your function and it works fine, except when I was including " and had to later present
the content of the db field in a web page: anything after the fisrt " was not presented, so I
found a solution that works also in this case, substituting the straight double quotes with the
oblique double quotes.
I re-write the function here:
Original function:
function reverse_escape($str)
{
$search=array("\\\\","\\0","\\n","\\r","\Z","\'",'\"');
$replace=array("\\","\0","\n","\r","\x1a","'",'"');
return str_replace($search,$replace,$str);
}
New function:
function resc($txt){
$search=array("\\\\","\\0","\\n","\\r","\Z","\'",'\"');
$replace=array("\\","\0","\n","\r","\x1a","'",'â');
return str_replace($search,$replace,$txt);
}
I hope it can help someone. Best regards to all