【问题标题】:Phpmyadmin blob php image coming out encrypted, want to display blob images to webpagePhpmyadmin blob php 图像加密出来,想要在网页上显示 blob 图像
【发布时间】:2015-04-03 15:25:32
【问题描述】:

问题出在这里:

代码是加密出来的,所以我无法在网页上显示 blob 图像,我希望 blob 显示为图像:

<?php
//connect to server
$connect = mysql_connect("localhost","root","");

//connect to database
mysql_select_db("website");

//query the database
$query = mysql_query("SELECT * FROM homepage");

//fetch results of database and convert to an array

while($rows = mysql_fetch_array($query)):
//

    echo "<div class = 'productBox1'>";
        echo "<img class = 'pImg1' src='{$rows['image']}' />";
        echo "<div class = 'pDesk1'>" . "<p>" . $rows['description'] . "</p>" . "</div>";
    echo "</div>";
//
endwhile;

?>

【问题讨论】:

    标签: php html mysql css


    【解决方案1】:

    尝试将其插入到您的 php 代码中

    $rows['image'] = base64_decode($rows['image']);
    

    编辑:确保您使用

    将图像放入数据库
    $image = base64_encode($image);
    

    【讨论】:

      【解决方案2】:

      用这个编辑while循环。

      while($rows = mysql_fetch_array($query))
      {
      $rows['image'] = base64_decode($rows['image']);
      $image = $rows['image'];
      $desc = $rows['description'];
      ?>
      echo "<div class = 'productBox1'>";
          echo "<img class = 'pImg1' src=<?php echo $image;?> />";
          echo "<div class = 'pDesk1'>" . "<p>" . $desc . "</p>" . "</div>";
      echo "</div>";
      <?php
      }
      ?>
      

      【讨论】:

        【解决方案3】:

        将数组更改为 assoc 看看是否有帮助(: 所以你的while循环看起来像这样 while($rows = mysql_fetch_assoc($query)):

        【讨论】:

        • @user3135672 尝试将表结构从blob更改为longtext,如果不行,您介意共享表结构吗?我会尝试通过查看我的计算机出了什么问题来解决这个问题。
        猜你喜欢
        • 2017-07-28
        • 2013-06-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-31
        • 2014-03-19
        • 2013-12-28
        相关资源
        最近更新 更多