I am storing my image as BLOB in an online MySQL database by encoding the image using Base64. I don't have a problem with saving. But I can't retrieve the images from the server. They appear to be broken. I believe this is happening because it's not being decoded.
I tried manually uploading a couple of photos to the server, and they are retrieved properly since they are not encoded. This is the code I'm using to retrieve the image. Can someone please tell me how to decode the image?
<?php
$db = mysql_connect("localhost","un","pw") or die(mysql_error());
mysql_select_db("datab",$db) or die(mysql_error());
$userId = $_GET['eid'];
$query = "SELECT image FROM event WHERE eid='$userId'";
$result = mysql_query($query) or die(mysql_error());
$photo = mysql_fetch_array($result);
header('Content-Type:image/png;base64');
echo $photo['image'];
?>