note 122016 added to mysqli.real-escape-string
| From: | LawrenceDOliveiro@php.net | Date: | Wed, 13 Dec 2017 03:56:47 +0000 |
| Subject: | note 122016 added to mysqli.real-escape-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209358@lists.php.net to get a copy of this message | ||
Note that the âlikeâ operator requires an *additional* level of escaping for its special
characters, *on top of* that performed by mysql_escape_string. But there is no built-in function for
performing this escaping. Here is a function that does it:
function escape_sql_wild($s)
/* escapes SQL pattern wildcards in s. */
{
$result = array();
foreach(str_split($s) as $ch)
{
if ($ch == "\\" || $ch == "%" || $ch == "_")
{
$result[] = "\\";
} /*if*/
$result[] = $ch;
} /*foreach*/
return
implode("", $result);
} /*escape_sql_wild*/
----
Server IP: 208.43.231.9
Probable Submitter: 118.92.45.19
----
Manual Page -- http://php.net/manual/en/mysqli.real-escape-string.php
Edit -- https://master.php.net/note/edit/122016
Del: integrated -- https://master.php.net/note/delete/122016/integrated
Del: useless -- https://master.php.net/note/delete/122016/useless
Del: bad code -- https://master.php.net/note/delete/122016/bad+code
Del: spam -- https://master.php.net/note/delete/122016/spam
Del: non-english -- https://master.php.net/note/delete/122016/non-english
Del: in docs -- https://master.php.net/note/delete/122016/in+docs
Del: other reasons-- https://master.php.net/note/delete/122016
Reject -- https://master.php.net/note/reject/122016
Search -- https://master.php.net/manage/user-notes.php