View Single Post
Join Date: Oct 2008
Posts: 8
Reputation: twmprys is an unknown quantity at this point 
Solved Threads: 0
twmprys twmprys is offline Offline
Newbie Poster

Can't get images to display in database

 
0
  #1
Oct 12th, 2008
Yes, I know this is a common one, but I've inserted images in a database and can't for the life of me get them to display. And before anyone suggests I shouldn't do it, they are only small pictures and a maximum of four. I am currently using two pages to display the pictures. This is the main page:
  1. <?
  2. mysql_connect("localhost", "username", "password") OR die(mysql_error());
  3. mysql_select_db("debname") OR die(mysql_error());
  4. $result=mysql_query("SELECT * FROM newyddion") OR die("Can't Perform Query");
  5. While($row=mysql_fetch_object($result)) {
  6. echo "<IMG SRC=\"picupload3.php3?id=$row->id\">";
  7. }
  8. ?>
And this is the supporting page (i.e. picupload3.php3):
  1. <?php
  2. ini_set("register_globals",1);
  3. mysql_connect("localhost", "username", "password") or die(mysql_error());
  4. mysql_select_db("debname") or die(mysql_error());
  5. $result=mysql_query("SELECT pic1 FROM newyddion WHERE id=$id") or die("Can't perform Query");
  6. $row=mysql_fetch_object($result);
  7. Header( "Content-type: image/jpg");
  8. echo $row->pic1;
  9. ?>
Last edited by cscgal; Oct 13th, 2008 at 12:26 pm. Reason: Added code tags
Reply With Quote