显示破碎的图像 - PHP

Im trying to display BLOB type image from my database, but its not working. I`m getting broken image showed.

Upload to database code:

 <form method="post" enctype="multipart/form-data">
            <br/>
            <input type="file" name="image" />
            <br/><br/>
            <input type="submit" name="sumit" value="Upload" />
            <?php  $imagee= file_get_contents(DB::query("SELECT profile_img FROM users WHERE id=:userid", array(':userid'=>$userid)));
            $type= DB::query("SELECT mime FROM users WHERE id=:userid", array(':userid'=>$userid));
                   echo '<img height="300" width="300" src="data:'.$type.';base64,'. base64_encode(stripslashes($imagee)).'"> ';
          ?>
        </form>
        <?php
       if(isset($_POST['sumit']))
        {
            if(getimagesize($_FILES['image']['tmp_name'])==FALSE)
            {
                echo "Choose photo.";
            }
            else
            {
                $image= addslashes($_FILES['image']['tmp_name']);
                $name= addslashes($_FILES['image']['name']);
                $type= addslashes($_FILES['image']['type']);
                $image= file_get_contents($image);
                $image= base64_encode($image);
                DB::query("UPDATE users SET profile_img = :profile_img, mime=:mime WHERE id=:userid", array(':profile_img'=>$image,':mime'=>$type, ':userid'=>$userid));
            }
        }

Display image code:

  <?php  $imagee= file_get_contents(DB::query("SELECT profile_img FROM users WHERE id=:userid", array(':userid'=>$userid)));
            $type= DB::query("SELECT mime FROM users WHERE id=:userid", array(':userid'=>$userid));
                   echo '<img height="300" width="300" src="data:'.$type.';base64,'. base64_encode(stripslashes($imagee)).'"> ';
          ?>

You have encoded image while saving to Database.

And while fetching it and displaying it, you are again encoding it.

You should decode it.

Corrected Code:

<?php
$sql = ""SELECT profile_img FROM users WHERE id=:userid"";
$imagee= file_get_contents(DB::query($sql, array(':userid'=>$userid)));
$typeSQL = "SELECT mime FROM users WHERE id=:userid";
$type= DB::query($typeSQL, array(':userid'=>$userid));
echo '<img height="300" width="300" src="data:'.$type.';base64,'. base64_decode(stripslashes($imagee)).'"> ';
?>