图片没有显示

时间:2017-07-02 07:49:10

标签: php html database image photo

我使用了filedisplay.php?id =方法来显示用户选择的产品。图片显示在数据库的索引上,但未显示在filedisplay.php上:(

我的filedisplay.php

    <?php
include 'fileconstant.php';
 // just so we know it is broken
 error_reporting(E_ALL);
 // some basic sanity checks
 if(isset($_GET['id']) && is_numeric($_GET['id'])) {
     //connect to the db
     $link = mysql_connect("$host", "$user", "$pass")
     or die("Could not connect: " . mysql_error());

     // select our database
     mysql_select_db("$db") or die(mysql_error());

     // get the image from the db
     $sql = "SELECT photo FROM products WHERE id=" .$_GET['id'] . ";";

     // the result of the query
     $result = mysql_query("$sql") or die("Invalid query: " . mysql_error());

     // set the header for the image
     header("Content-type: image/jpeg");
     echo mysql_result($result, 0);

     // close the db link
     mysql_close($link);
 }
 else {
     echo 'Please use a real id number';
 }
?>

这是问题,如下图所示!

0 个答案:

没有答案