Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

mysql blob images

10:58 am on Nov 11, 2008 (gmt 0)

Junior Member from ZA 

10+ Year Member

joined:Sept 19, 2008
posts: 53
votes: 0

Hi there
I want to develop a php webpage where all the jpg photos uploaded in the mysql database table tbl_images can be displayed.

Instead of showing the photos the code below shows some alien language and a warning like this:
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\phpvt
SPi~ 1e^?+ J6e3CsY*Ѵ }GZxD=53mVqس1f'$Mh@ <Uf+ڹZ umG u- wл KZYVoX l d\ I },}-8uոfE`0 dcy p"1a =( }x+ \ LĿ0%

Here is the database structure:
dbname= test
table= tbl_images
id=int primary key not null auto increment
image= blob
description= text

The php code is as follows:
$username = "*****";
$password = "*****";
$host = "localhost";
$database = "test";
@mysql_connect($host, $username, $password) or die("Can not connect to database: ".mysql_error());
@mysql_select_db($database) or die("Can not select the database: ".mysql_error());
$query = mysql_query("SELECT * FROM tbl_images");
$row = mysql_fetch_array($query);
$content = $row['image'];
header('Content-type: image/jpg');
echo $content;

What can I do or alter in this code to make the page display the image? I have been looking all over the internet with no success. Pls help

12:20 pm on Nov 11, 2008 (gmt 0)

Full Member

10+ Year Member

joined:Feb 4, 2004
votes: 0

Make sure that the PHP opening tag <?php is at the beginning of the first line of your file. When you output images, no empty lines, white spaces or any other characters are allowed before the <?php.