RSS Forums RSS

Can't get images to display in database

Please support our MySQL advertiser: Programming Forums
Reply
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

  #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 11:26 am. Reason: Added code tags
AddThis Social Bookmark Button
Reply With Quote  
Posts: 161
Reputation: mwasif is an unknown quantity at this point 
Solved Threads: 22
mwasif mwasif is offline Offline
Junior Poster

Re: Can't get images to display in database

  #2  
Oct 14th, 2008
This post might help you to do things right.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Views: 851 | Replies: 1 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:14 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC