PDO无法从数据库中获取图像

时间:2014-01-14 10:41:45

标签: php database image pdo blob

我在下面发布了我的代码。我可以从数据库中获取文本值。但是,我无法获取图像。我不知道我哪弄错了?

      try
        {
            $stmt = $conn->prepare("SELECT * FROM ebusers");
            $conn->errorInfo();
            $stmt->execute();
            while($userrow = $stmt->fetch())
            {
                echo "<table class=glowing width=800 border=0 align=center cellpadding=0 cellspacing=0>";
                echo "<tr>";
                echo "<td height=40 colspan=3 class=user_id >User ID : " . $userrow['UserID'] . "</td>";
                echo "</tr>";
                echo "<tr>";
                echo "<td bgcolor=wheat colspan=3>&nbsp;</td>";
                echo "</tr>";
                echo "<tr>";
                echo '<td width=334 rowspan=9 bgcolor=wheat align=center >';
                if( $userrow['UserProfilePicture'] >= '[BLOB - 0B]' )
                    {
                        echo '<img class=shadow_img width=160 height=180 src="data:image/png;base64,'  . base64_encode($userrow['UserProfilePicture']) . '"/>';
                    }
                else
                    {
                        echo '<img src=\'images/nophoto.gif\' class=shadow_img width=160 height=180 />';
                    }
            echo "<tr>";
            echo "<td bgcolor=wheat style=\"border-bottom-right-radius:5px; border-bottom-left-radius:5px;\" colspan=3>&nbsp;</td>";
            echo "</tr>";
            echo "</table>";
            echo "<br>";
            echo "<br>";
            }
        }
        catch(PDOException $e)
        {
            'Error : ' .$e->getMessage();
        }

0 个答案:

没有答案