I read this tutorial about storing images in DB. In the tutorial, the author escapes special characters in the binary data before inserting: http://www.phpriot.com/articles/images-in-mysql/7 ( using addslashes
although mysql_real_escape_string
is preferable - but that is another issue ).
The point is, when displaying, he just displays the data as it is stored: http://www.phpriot.com/articles/images-in-mysql/8
My questions:
1) Do we need to escape special characters even for binary field type (blob
)?
2) If so, then, do we not need to "unescape" the characters again in order to display the image correctly? (If so, what is the best way to do it. Any comments about efficiency? For large images: escaping and unescaping can be a big overhead?).
Or is it that my understanding about escaping is totally wrong (and escaping only affects the query and not the final data inserted/stored?).
thanks
JP