perlmonger Posted December 18, 2006 Share Posted December 18, 2006 I'm having difficulty getting usable binary data out of a mysql database. I'm uploading and storing a pdf file in a mediumblob column in mysql and then trying to serve it up to the browser. It's pretty obvious that the problem lies in the escaping and unescaping of the binary data. I've tried addslashes() and mysql_escape_string() to escape the data before storing and stripslashes() on retrieval to unescape but still get corrupted data. I'm using PHP 4.2.3 with magic quotes "ON" and magic quotes runtime "OFF". With magic quotes "on" I would think that I wouldn't have to use addslashes() or any kind of escaping but I can't insert the data without some escaping. I get a sql error since it finds a double-quote character in the binary data. It seems that magic quotes doesn't do exactly what I think it does. The PHP docs indicate that the slashes added by addslashes() are not actually stored in the database but only used to escape the data during insert and somehow discarded. That would be the desired behavior since one wouldn't have to remove them upon retrieval. Can someone help me figure out what I need to do here? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.