943,836 Members | Top Members by Rank

Ad:
  • MySQL Discussion Thread
  • Unsolved
  • Views: 1193
  • MySQL RSS
Oct 12th, 2008
0

Can't get images to display in database

Expand Post »
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:
mysql Syntax (Toggle Plain Text)
  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):
php Syntax (Toggle Plain Text)
  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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
twmprys is offline Offline
8 posts
since Oct 2008
Oct 14th, 2008
0

Re: Can't get images to display in database

This post might help you to do things right.
Reputation Points: 29
Solved Threads: 47
Posting Whiz
mwasif is offline Offline
312 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MySQL Forum Timeline: phpMyAdmin error
Next Thread in MySQL Forum Timeline: please help (what's wrong?)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC