Re: [PHP-DB] SHOW PICTURE FROM DATABASE

2002-12-31 Thread nikos
I've done it allredy!
It brings up a line of unknown characters

  - Original Message - 
  From: John W. Holmes 
  To: 'Nikos Gatsis' ; 'PHP-mailist' 
  Sent: Tuesday, December 31, 2002 1:08 AM
  Subject: RE: [PHP-DB] SHOW PICTURE FROM DATABASE


   I have a php script that call binary data of pictures stored in
  database.
   The script works fine in IE but not in Netscape (ver 4.7,   6.01).
   Any ideas?
   
   -
   the html tag is like: img src=showpict.php?pro_id=1
   
   where showpict.php:
   
$query=SELECT pict FROM pict WHERE pro_id= '$pro_id;
$result=mysql_db_query($database, $query, $conn) or Die
  (mysql_error());
list($photo)=mysql_fetch_row($result);
$type = $photo_type;
if (!empty($photo)) {
 header(Content-Type: {$type});
 echo $photo;
}

  Call up showpict.php?pro_id=1 in Netscape and see if you get an error.
  Just type it in and call it up by itself.

  ---John W. Holmes...

  PHP Architect - A monthly magazine for PHP Professionals. Get your copy
  today. http://www.phparch.com/





Re: [PHP-DB] SHOW PICTURE FROM DATABASE

2002-12-31 Thread Steve Cayford

On Tuesday, December 31, 2002, at 02:25  AM, nikos wrote:


Steve
 
b. the _type is the type of the binary data. From the PHP manual 
read: $userfile_type - The mime type of the file if the browser 
provided this information. An example would be image/gif

Ok, but it didn't look like you saved the type information in the 
database, at least it wasn't in your query, so where is it coming from? 
I mean tacking _type on the variable doesn't magically tell you the 
mime type except in the case of file uploads (where the type is 
supplied by the browser), right?

Ready to stand corrected...

-Steve


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] SHOW PICTURE FROM DATABASE

2002-12-30 Thread Steve Cayford
Some suggestions...

On Monday, December 30, 2002, at 03:55  PM, Nikos Gatsis wrote:

where showpict.php:

 $query=SELECT pict FROM pict WHERE pro_id= '$pro_id;


(You're missing an end ' there, but apparently that's not the problem)


 $result=mysql_db_query($database, $query, $conn) or Die 
(mysql_error());
 list($photo)=mysql_fetch_row($result);
 $type = $photo_type;

Where did the $photo_type variable come from? What's in it?


 if (!empty($photo)) {
  header(Content-Type: {$type});


I believe this header should be in the form header(Content-Type: 
image/jpeg) or whatever image type you have.

You should probably include an additional header
header(Content-Length:  . strlen($photo));

  echo $photo;
 }

THANX
Nikos



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP-DB] SHOW PICTURE FROM DATABASE

2002-12-30 Thread John W. Holmes
 I have a php script that call binary data of pictures stored in
database.
 The script works fine in IE but not in Netscape (ver 4.7,   6.01).
 Any ideas?
 
 -
 the html tag is like: img src=showpict.php?pro_id=1
 
 where showpict.php:
 
  $query=SELECT pict FROM pict WHERE pro_id= '$pro_id;
  $result=mysql_db_query($database, $query, $conn) or Die
(mysql_error());
  list($photo)=mysql_fetch_row($result);
  $type = $photo_type;
  if (!empty($photo)) {
   header(Content-Type: {$type});
   echo $photo;
  }

Call up showpict.php?pro_id=1 in Netscape and see if you get an error.
Just type it in and call it up by itself.

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php