Re: Storing image in database
| From: | Daniel Schierbeck | Date: | Mon, 30 Aug 2004 18:57:02 +0000 |
| Subject: | Re: Storing image in database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195182@lists.php.net to get a copy of this message | ||
Dre wrote:
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 first of all, does the column 'image_type' hold the mime-type of the image? If yes, then you should use $image_type instead of $image in your header. I'm not sure if you can use print() like you do there...-- Daniel Schierbeck