简体   繁体   中英

php ,mysql image is not displaying from database

image is not displaying from the database it show just showing broken image

<?php
$con = mysql_connect('localhost', 'root', ''); //Update hostname
mysql_select_db("postad", $con); //Update database name
$query = "SELECT path1 FROM img_tbl";
$result = mysql_query($query) or die('Error : ' . mysql_error());
$row = mysql_fetch_array($result);
$photo = $row['path1'];
 echo "<center><img src=$photo alt=Profile Photo>";
?>

$photo is path right

then try this

echo '<center><img src='.$photo.'alt="Profile Photo"></center>';

从注释移开,这是您需要的解决方法:

echo '<center><img src= '.$photo.' alt="Profile Photo"></center>';

Change second last line with this

echo '<center><img src="'.$photo.'" alt="Profile Photo"></center>';

This will work if $photo path is correct...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM