By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,810 Members | 783 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,810 IT Pros & Developers. It's quick & easy.

image displaying problem php

P: 7
PLz Help
i have some Images in DataBase in Blob field
but images are displayed with a Cross (X) not the actual image

MainPage.php//code

Expand|Select|Wrap|Line Numbers
  1. # <?php
  2. # $con = mysql_connect("localhost","root","");
  3. # if (!$con)
  4. #    die('Could not connect: ' . mysql_error());
  5. # mysql_select_db("db1", $con);
  6. # $image = mysql_query("SELECT * FROM userimagetable");
  7. # while($imageResult = mysql_fetch_array($image) ){
  8. #     ?>
  9. #     <img src="ViewImage.php?id=<?=$imageResult['id']?>" alt="Picture" /></td></tr>
  10. #     <?php 
  11. # }
  12. #  
  13. # and the other file displaying image code is
  14. #  
  15. # ViewImage.php
  16. # <?php
  17. # $id = $_GET['id'];
  18. # $image = mysql_query("SELECT * FROM userimagetable WHERE Id='".$id."'");
  19. # $imageResult = mysql_fetch_array($image);
  20. #     header("Content-type: image/jpg");
  21. # echo $imageResult['UserImage'];
  22. # ?>
  23.  
Apr 2 '09 #1
Share this Question
Share on Google+
6 Replies


Markus
Expert 5K+
P: 6,050
I'll hazard a guess and say you're not setting the correct content-type?

What happens is you try and go to ViewImage.php?id=someid (substituting someid for a valid id)?
Apr 2 '09 #2

P: 7
i have removed the header for the file
[code=php]
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
die('Could not connect: ' . mysql_error());
mysql_select_db("image", $con);
//header('Content-type: image/jpeg');
$query = "SELECT image from images where id=1";
$rs = mysql_fetch_array(mysql_query($query));
echo base64_decode($rs["image"]);
[/code=php]
Apr 2 '09 #3

P: 7
all images are only jpg in database
Apr 2 '09 #4

Markus
Expert 5K+
P: 6,050
Like I said, what happens when you visit the page that displays the image. Note: not the image tag, the actual image serving page.
Apr 2 '09 #5

P: 7
Displaying image from database

and displays image region in a square with a red Cross {X} in the image area
and not displaying the actual image
Apr 2 '09 #6

P: 7
the page is error free


contents of the page are

"
Displaying image from database
Image [with Cross]
"
Apr 2 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.