html - Image retrieved in PHP is not displaying properly
Get the solution ↓↓↓I am having trouble with displaying images with php. I have tried this question, but it's still not displaying properly.
I have a PHP file that is handling the HTML format, the code for the image part is as follows:
while($row = mysql_fetch_array($result)) {
$partNo = $row['partNo'];
echo "<tr>";
echo '<td> <img src="getThumb.php?id =\''. $partNo .'\' width="50" height="50" /> </td>';
My getThumb.php is as follows:
<?php
$id = $_GET['id'];
$con = mysql_connect("localhost", "root", "root") or die("Unable to connect to server");
mysql_select_db("bmworld.mu");
$sql = "SELECT thumbnail FROM part WHERE partNo=$id" or die ("Could not fetch thumbnail");
$result = mysql_query("$sql");
$row = mysql_fetch_object($result);
mysql_close($con);
header("Content-type: image/jpeg");
echo $row['thumbnail'];
?>
The results is as follows:
http://postimg.org/image/xqcq16ucf/
My image is of type 'blob' saved in MySQL, and not a path to the image folder. I want to retrieve that blob from MySQL, and display it directly from the retrieved blob instead of a path to the image, just like the other columns of data from my database table. How can I do this?
Answer
Solution:
There are following problems may be in your code:-
your image path is not correct (what you are saving in your database).
Either you are saving your image directly with blob data-type and at the time retrieval you face some problem.
For the first problem try to hardcode path of your image and check, if working then your path saving to databsae is not correct and you have to correct.
For second problem please check this link:PHP display image BLOB from MySQL. It will definitely help you. Thanks.
Answer
Solution:
are u sure that getThumb.php has good file location?
<img src="getThumb.php?id =\''. $partNo .'\' width="50" height="50" />
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the process class relies on proc_open, which is not available on your php installation.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.