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;
?>

This post might help you to do things right.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.