Re: Storing image in database
| From: | Daniel Schierbeck | Date: | Mon, 30 Aug 2004 20:22:52 +0000 |
| Subject: | Re: Storing image in database | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195200@lists.php.net to get a copy of this message | ||
Dre wrote:
line 8 is <?php just that .. and the code before it is the following //================================================== <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> //================================================== "Marek Kilimajer" <lists@kilimajer.net> wrote in message news:413378B0.5020108@kilimajer.net...<?php ob_start() ?> <html> <head>... <?php include '...'; // Blabla ?> -- Daniel SchierbeckDre wrote:saveHi .. I'm trying to save and view image files in a MySQL database, I made thepreviouslyoperation 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//==========================================================================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; }(output================= Everytime I try to execute this code I get this error Warning: Cannot modify header information - headers already sent byFiles\Apachestarted at C:\Program Files\Apache Group\Apache2\htdocs\ELBA\admin\Untitled-1.php:8) in C:\ProgramGroup\Apache2\htdocs\ELBA\admin\Untitled-1.php on line 18If the script you posted is Untitled-1.php you did not post the whole script. You output something on line 8, possibly a white space. You cannot output anything before any header(), setcookie(), or session_start() function calls. And header("Content-type: $image); should be header("Content-type: $image_type); That's why the script fucks up. You cannot send any output to the browser prior to a header. Either send the header before you send the HTML or use output buffering, eg.: