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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.