Jump to content

mysql_escape_string and binary data


scarhand

Recommended Posts

when i insert binary data into my database it is supposed to be inserting the exact same data in 2 places, but its not.

 

this data i am inserting is "h—ù×Ç6šª\0UOÛ¹ð+`" (binary), notice the backtick on the end of it...

 

now when i insert this value using this script:

 

<?php
$hash = mysql_real_escape_string($hash);

mysql_query("INSERT INTO test (hash) VALUES ('$hash')");
?>

 

using that inserts "h—ù×Ç6šª\0UOÛ¹ð+`" which is 100% correct, notice the backtick is still there

 

now when i insert this value using this script:

 

<?php
$columns = '`hash`';
$values = '\'' . mysql_escape_string($hash)  . '\'';
@mysql_query("REPLACE INTO `test2` ($columns) VALUES ($values);");
?>

 

using that inserts "h—ù×Ç6šª\0UOÛ¹ð+" (notice the backtick is gone from the end of this one, and its only 19 characters in length as opposed to 20)

 

the difference between the table 'test' and 'test2' is 'test2' is a HEAP type

 

also, 'test' uses char(20) binary as its column for 'hash', where 'test2' uses varchar(20) binary as its column for 'hash'..

 

any help would be great.

Link to comment
https://forums.phpfreaks.com/topic/93772-mysql_escape_string-and-binary-data/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.