sainadh reddy
sainadh reddy

Reputation: 65

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>";
?>

Upvotes: 1

Views: 3186

Answers (3)

Change second last line with this

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

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

Upvotes: 1

DirtyBit
DirtyBit

Reputation: 16772

Moving from the comments, this is the fix you need:

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

Upvotes: 2

Pranavadurai
Pranavadurai

Reputation: 1030

$photo is path right

then try this

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

Upvotes: 4

Related Questions