php - Inserting a custom binary format blob into SQL -


i have log file made in custom binary format. log file uploaded server , php inserts mysql database, so

$tmpname = $_files['file']['tmp_name']; $fp = fopen($tmpname, 'r'); $content = fread($fp, filesize($tmpname)); $query = "insert device_log (did, devicelog) values ( '$res1', '$content')"; 

but doesn't work, because sql has trouble contents, giving you have error in sql syntax; check manual corresponds mysql server version right syntax use near '««»»qì™úx' @ line 1 error.

i've read need escape data mysql_real_escape_string, ruin initial data, i.e. wouldn't able read back. correct way insert such blob?

you might want base64 encode data before insertion database, might alleviate issue (you need base64 decode data when reading back).


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -