0

Hello,

I need help on this...

I try to insert image from mysql into my php table.... but the output inside the image table are unknown characters

Sm.l1ZQmMԽok*5l0P9fI$A3tu4ZJǽ_t/&[{Ro; :I%yҩ?u\t_Ǡ]N>Bz9ҥ=hƬկdw~hY4Ef%MC 1IP@zP&rj֩k޺8apbSMytCoQ$?ZF*S9حRxh9$J \m,[6^CctqU%K$%84leniX\B!s9n;1F~t䎪:E+7R["! 1ZݞzQ>(zSxѹ 5⺞mG%֦k/9]_4!4}hI
2
Contributors
3
Replies
6
Views
6 Years
Discussion Span
Last Post by niranga
0

You have to write a separate PHP file to get the image. In that file you have to fetch the image data from the data base and send it back
Following is an example (getImage.php)

<?php
        // getImage.php file

	// Connect to the database here 
	 
	$result = mysql_query("SELECT image FROM gallery WHERE id='".$_GET['id']."'");
	$row = mysql_fetch_array($result, MYSQL_ASSOC);
	header("Content-type: image/jpeg");
	echo $row['image'];
?>

Then you can pass the id and fetch the image. So in your code, in the place you want to display the image, call getImage.php?id=<id_value> in <img> tag's src attribute

// Inside the while loop of yours
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td><img src='getImage.php?id".$row['id']."'/></td>";
echo "<td>".$row['time']."</td>";
echo "</tr>";
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.