need your help to retrieve images

images php coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
kyle04
New php-forum User
New php-forum User
Posts: 94
Joined: Sat Jul 07, 2012 1:36 pm

Wed Jul 25, 2012 1:45 am

echo"<image src=getimage.php?id=$lastid >";
is not a valid file path to display an image.

AndyP

kyle04
New php-forum User
New php-forum User
Posts: 94
Joined: Sat Jul 07, 2012 1:36 pm

Thu Jul 26, 2012 2:26 pm

It depends how the image information is stored.
the most efficient would be to have the image path stored as a field in you db table, say "topic_image" , in the format topicimage.jpg .
If the images are stored in the directory www.domain.com/images :

so the retrieve the image for that page :

$img = "images/".$row['topic_image'];

echo "<img src=\"$img\">";

which would translate to : <img src="images/topicimage.jpg">

kyle04
New php-forum User
New php-forum User
Posts: 94
Joined: Sat Jul 07, 2012 1:36 pm

Sat Jul 28, 2012 2:09 pm

Same variable name being used for different variables :
$image= mysql_query ("SELECT photo FROM tourisn_news Where id=$id");
$image = mysql_fetch_assoc($image);
$image= $image22['photo'];
header("content-type:image/jpeg");
echo $image;
1) $image= mysql_query ("SELECT ......
You've chosen "$image" as your query name

2 $image = mysql_fetch_assoc($image);
should be like :
$row = mysql_fetch_assoc($image);

3) $image= $image22['photo'];
should be :
$this_image= $row['photo'];


echo <img src=\"$this_image\">;

Post Reply