homepage Welcome to WebmasterWorld Guest from 54.227.20.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
mysql blob images
phex

5+ Year Member



 
Msg#: 3784002 posted 10:58 am on Nov 11, 2008 (gmt 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
taken_by=varchar(50)
email=varchar(50)
time=timestap

The php code is as follows:
<?php
$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

 

adb64

10+ Year Member



 
Msg#: 3784002 posted 12:20 pm on Nov 11, 2008 (gmt 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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved