OnDWay
OnDWay

Reputation: 139

php display image

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'];
?>

Upvotes: 0

Views: 218

Answers (2)

OptimusCrime
OptimusCrime

Reputation: 14863

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.

Upvotes: 1

Siva Charan
Siva Charan

Reputation: 18064

Have you tried this way:-

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

Upvotes: 0

Related Questions