在我插入标题后('Content-Type:image / png'),屏幕变黑,但是如果我把这个代码变成乱码

require_once('PdoDb.class.php');
$db=PDOconnection::getconnection();
$query = "select * from users WHERE uid = '6'"; 
$stmt = $db->prepare( $query );

$stmt->bindParam(1, $_GET['id']);
$stmt->execute();


$num = $stmt->rowCount();

if($num ){

 $row = $stmt->fetch(PDO::FETCH_ASSOC);
 echo "<script>alert('scucess');</script>";

$r=$row['image'];


header('Content-Type: image/png');
echo file_get_contents("$r");

//echo readfile('<img src="'.$r.'" alt="HTML5 Icon" style="width:128px;height:128px">');

}echo json_encode($result_array);

i want to display the images from users but got error to make the screen become all back after i insert the header inside , but the connection is ok