DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   MySQL (http://www.daniweb.com/forums/forum126.html)
-   -   Can't get images to display in database (http://www.daniweb.com/forums/thread150802.html)

twmprys Oct 12th, 2008 11:14 pm
Can't get images to display in database
 
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_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("debname") or die(mysql_error());
$result=mysql_query("SELECT * FROM newyddion") or die("Can't Perform Query");
While($row=mysql_fetch_object($result)) {
echo "<IMG SRC=\"picupload3.php3?id=$row->id\">";
}
?>
And this is the supporting page (i.e. picupload3.php3):
<?php
ini_set("register_globals",1);
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("debname") or die(mysql_error());
$result=mysql_query("SELECT pic1 FROM newyddion WHERE id=$id") or die("Can't perform Query");
$row=mysql_fetch_object($result);
Header( "Content-type: image/jpg");
echo $row->pic1;
?>

mwasif Oct 14th, 2008 4:10 pm
Re: Can't get images to display in database
 
This post might help you to do things right.


All times are GMT -4. The time now is 7:01 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC