note 82015 added to function.mysql-real-escape-string
| From: | BastiaanWelmers at osu1 dot php dot net | Date: | Mon, 24 Mar 2008 19:46:52 +0000 |
| Subject: | note 82015 added to function.mysql-real-escape-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137463@lists.php.net to get a copy of this message | ||
This function won't help you when inserting binary data, to me it will get mallformed into the
database. Probably UTF-8 combinations will be translated by this function or somewhere else when
inserting data when running mysql in UTF-8 mode.
A better way to insert binary data is to transfer it to hexadecimal notation like this example:
<?php
$string = $_REQUEST['string'];
$binary = file_get_contents($_FILE['file']['tmp_name']);
$string = mysql_real_escape_string($string);
$binary_hex = bin2hex($binary);
$query = "INSERT INTO
table (key, string,
binary, other) VALUES (NULL, '$string', 0x$binary_hex,
'$other')";
?>
----
Server IP: 83.137.20.135
Probable Submitter: 2001:888:1cb2:1:20d:61ff:fe55:8bb
----
Manual Page -- http://www.php.net/manual/en/function.mysql-real-escape-string.php
Edit -- https://master.php.net/note/edit/82015
Del: integrated -- https://master.php.net/note/delete/82015/integrated
Del: useless -- https://master.php.net/note/delete/82015/useless
Del: bad code -- https://master.php.net/note/delete/82015/bad+code
Del: spam -- https://master.php.net/note/delete/82015/spam
Del: non-english -- https://master.php.net/note/delete/82015/non-english
Del: in docs -- https://master.php.net/note/delete/82015/in+docs
Del: other reasons-- https://master.php.net/note/delete/82015
Reject -- https://master.php.net/note/reject/82015
Search -- https://master.php.net/manage/user-notes.php