note 80886 added to function.mysql-real-escape-string
| From: | Mister at osu1 dot php dot net | Date: | Tue, 05 Feb 2008 18:50:53 +0000 |
| Subject: | note 80886 added to function.mysql-real-escape-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135797@lists.php.net to get a copy of this message | ||
Don't forget to escape the escape characters in a LIKE clause!
Basically, you want to first escape the \ character, then use the mysql escape function, then escape
the % and _ special characters.
For example:
<?
$param = preg_replace( '/\\\\/u', '\\\\\\\\', $param );
$param = mysql_real_escape_string($param);
$param = preg_replace( '/([%_])/u', '\\\\$1', $param );
?>
(this example assumes you are working with Unicode, hence the 'u' parameters to the
regular expressions)
----
Server IP: 190.54.16.132
Probable Submitter: 200.111.44.195
----
Manual Page -- http://www.php.net/manual/en/function.mysql-real-escape-string.php
Edit -- https://master.php.net/note/edit/80886
Del: integrated -- https://master.php.net/note/delete/80886/integrated
Del: useless -- https://master.php.net/note/delete/80886/useless
Del: bad code -- https://master.php.net/note/delete/80886/bad+code
Del: spam -- https://master.php.net/note/delete/80886/spam
Del: non-english -- https://master.php.net/note/delete/80886/non-english
Del: in docs -- https://master.php.net/note/delete/80886/in+docs
Del: other reasons-- https://master.php.net/note/delete/80886
Reject -- https://master.php.net/note/reject/80886
Search -- https://master.php.net/manage/user-notes.php