0

I am not able to display image using this code. Could any one help me in correcting?

<?php
include("connect.php");
$sql="select * from profile where userid=3";
$row=mysql_query($sql);
header("Content-type: image/jpeg");
echo $row['image'];
?>
1
  • Need more information. Do you save the image as raw text in the database? And tell us, what exactly is not working. Commented Nov 11, 2011 at 8:17

2 Answers 2

1

Try

<?php
include("connect.php");
$sql = "SELECT * FROM profile WHERE userid='3'";
$row = mysql_fetch_assoc(mysql_query($sql));
echo '<img src="'.$row['image'].'" />';
?>

Depends how your information is stored in the database. If you have stored the path to a picture, this will be the right way. If you have stored the whole picture, this must be done another way.

Sign up to request clarification or add additional context in comments.

Comments

0

Have you tried this way:-

echo "<img src=\"".$row['image']."\">";

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.