1

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>";
?>
15
  • Please avoid using the deprecated mysql functions Commented Sep 25, 2015 at 16:08
  • Did you do any basic debugging, like a view source to see the (broken) html you generated? deprecated means "don't use this anymore. it's obsolete and will be removed from PHP in a future version" Commented Sep 25, 2015 at 16:09
  • i dont know how to see Commented Sep 25, 2015 at 16:10
  • @HawasKaPujaari: that's broken. '-strings don't interpolate variables. Commented Sep 25, 2015 at 16:11
  • 1
    Thanks HawaKa u showed me solution Thanks a lot Commented Sep 25, 2015 at 16:26

3 Answers 3

4

$photo is path right

then try this

echo '<center><img src='.$photo.'alt="Profile Photo"></center>';
Sign up to request clarification or add additional context in comments.

Comments

2

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

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

Comments

1

Change second last line with this

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.