Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从mysql数据库中检索为blob图像时,图像被破坏_Php_Html_Mysql_Image - Fatal编程技术网

Php 从mysql数据库中检索为blob图像时,图像被破坏

Php 从mysql数据库中检索为blob图像时,图像被破坏,php,html,mysql,image,Php,Html,Mysql,Image,我每次都会被打破形象。请帮助我,我是新来的php。imagedata是我的名为property的表中blob类型的列,我在print.php文件中调用函数,如下所示 /*This is image.php file*/ $servername = "localhost"; $username = "root"; $password = " "; $dbname = "nevin"; // Create connection $conn = mysqli_connect($servername,

我每次都会被打破形象。请帮助我,我是新来的php。imagedata是我的名为property的表中blob类型的列,我在print.php文件中调用函数,如下所示

/*This is image.php file*/
$servername = "localhost";
$username = "root";
$password = " ";
$dbname = "nevin";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if (!isset($_GET['id'])) 
 {
//If not isset -> set with dumy value 
$_GET['id'] = "undefine"; 
$id=mysql_real_escape_string($_GET['id']);
}
$image = mysql_query("SELECT * FROM property where id = '$id'"); 
if($image) 
$image=mysql_fetch_assoc($image);
$image=$image['imagedata'];/*imagedata is column of blob type in my table       named property*/
header('Content-Type: image/jpg');/* in my database i have images in jpg  format and i am storing images as blob datatype*/
echo $image;
?>


<img src="image.php?id=<?php echo $row["id"]; ?>
/*this is my calling function in file print.php as shown below*/

/*print.php*/
<body>
<?php
$servername = "localhost";
 $username = "root";
 $password = " ";
 $dbname = "Nevin";

 // Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

$sql = "SELECT * FROM property";
$result = mysqli_query($conn, $sql);

?>


<section>
    <div class="features">
     <div class="l-container">
    <div class="content-wrap clearfix align-center">


        <?php



        while($row = mysqli_fetch_assoc($result))
        {

       echo '<div class="grid">';?>
            <img src="image.php? id=<?php echo $row["id"]; ?>" /><?php 
            echo '<h2>'.$row["id"].'</h2>'.
            '<p>'. $row["city"]. " " . $row["price"].'</p>'.
           '</div>';

          }
?>            
    </div>
</div>
</div>
</section>
</body>

更改此选项

<img src="image.php? id=<?php echo $row["id"]; ?>" />

检查此链接:-
<img src="image.php?id=<?php echo $row['id']; ?>"/>