Re: Storing image in database
| From: | Marek Kilimajer | Date: | Mon, 30 Aug 2004 18:57:52 +0000 |
| Subject: | Re: Storing image in database | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195183@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 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);