Re: Storing image in database

From: Date: Mon, 30 Aug 2004 19:58:16 +0000
Subject: Re: Storing image in database
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-195196@lists.php.net to get a copy of this message
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... > 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 > > If 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);

« previous php.general (#195196) next »