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

Recommended Answers

All 3 Replies

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>";

oh ... thank you so much man !.. it works.. :)

Welcome :) :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.