Using header() should be pretty much all you need to do.
// ...Connect to the DB server and select your database...
$result = mysql_query("SELECT image FROM myTable WHERE image_id = 1");
echo mysql_result($result, 0);
Assuming that the image data was inserted correctly into your database originally using something like - file_get_contents($_FILES['userfile']['tmp_name']) - to get the image itself, then it should work fine.
base64'ing binary data is good practice if your data contains things like single quotes that would likey break your query.
It's also handy for database systems that don't support a BLOG type field like older version of Microsoft SQL server. In these cases, you can base64_encode() your file and insert it into a TEXT field instead.
The Following User Says Thank You to Alan @ CIT For This Useful Post: