note 82015 deleted from function.mysql-real-escape-string by philip

From: Date: Fri, 04 Sep 2015 21:43:44 +0000
Subject: note 82015 deleted from function.mysql-real-escape-string by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203690@lists.php.net to get a copy of this message
Note Submitter: Bastiaan Welmers ---- 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')"; ?>

« previous php.notes (#203690) next »