Storing image in database
| From: | Dre | Date: | Mon, 30 Aug 2004 18:34:04 +0000 |
| Subject: | Storing image in database | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-195179@lists.php.net to get a copy of this message | ||
Hi ..
I'm trying to save and view image files in a MySQL database, I made the save
operation successfully, I stored the image file name, type, size and the
image file itself
the problem occurred when I tried to retrieve the image data I've previously
stored, in specific when I tried to preview the image file
I tried to make something like the following but it did not work
//==========================================================================
=================
<?php
include("db.php");
$sql = "select * from members_data where mem_id = '4335'";
$result = mysql_query($sql);
if(mysql_num_rows($result)>0)
{
$row = mysql_fetch_array($result);
$image_type = $row['image_type'];
$image = $row['personal_pic'];
header("Content-type: $image);
print $image;
}
//==========================================================================
=================
Everytime I try to execute this code I get this error
Warning: Cannot modify header information - headers already sent by (output
started at C:\Program Files\Apache
Group\Apache2\htdocs\ELBA\admin\Untitled-1.php:8) in C:\Program Files\Apache
Group\Apache2\htdocs\ELBA\admin\Untitled-1.php on line 18