I'm with Redcircle on this one - why store an image in the database?
every time you view an image you will have to instantiate a database connection, thus slowing it down for data retrieval scripts.
personally I cannot see one plausible reason for storing an image in a database that cannot be accomplished and surpassed by using filesystem storage or a combination of filesystem storage for the actual image and database storage for associated information.
Still, if you want to slow down your applications and seriously limit any extensibility of your scripts, I guess the choice is yours.
subnote: you could just about stream the binary data straight into an image tag...
echo '<img src="/-/data:image/jpeg;base64,' .$row['img']. '" />';
only works in a couple of browsers and the browser element size limit restricts it to 1KB (1024b), so is next to useless anyway.