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

Display image problem??

P: 21
I am having a problem in displaying the image. Image is stored perfectly but not able to retrieve and display...i tried to knowledge but still not able to get it..

my code is:
display.php
Expand|Select|Wrap|Line Numbers
  1.  
  2. <img src="displayimg.php?co=<?php echo $t;?>">
  3. \\$t is some id value i am sending to displayimg.php 
  4.  
displayimg.php
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php
  3.          $cpno=$_GET['co'];
  4.  
  5.          require_once('../includes/DbConnector.php');
  6.         $connector = new DbConnector();
  7.         $resim=$connector->query1("select img from image where compno=$1",array($cpno));
  8.          $im1=$connector->fetchArray($resim);
  9.          $data=pg_unescape_bytea(($im1[0]));
  10.  
  11.  
  12.           header('Content-type: image/jpeg');
  13.   echo $im1[0];
  14.  
  15.   ?>
  16.  
store.php
code which i used to store image is..
Expand|Select|Wrap|Line Numbers
  1.  $data = file_get_contents($newname);
  2. $imgdata =pg_escape_bytea($data);
  3.  require_once('../includes/DbConnector.php');
  4.         $connector = new DbConnector();
  5.         $connector->query1("INSERT INTO image VALUES($1,$2)",array($row[0],$imgdata));
  6.  
I am able to insert the data in to the table but not able to retrieve and display it..
i am sure that there is no syntactical parse errors..but my questions are...
Did i went any thing wrong in inserting??
Is there any setting in php.ini or httpd.conf files to display??
Please suggest me if i went wrong at any point...
Apr 24 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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