Broken Links 2
| From: | Rankin, Randy | Date: | Tue, 22 Oct 2002 19:05:20 +0000 |
| Subject: | Broken Links 2 | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-22599@lists.php.net to get a copy of this message | ||
Sorry about that first post, I prematurely hit send. Anyway, as I was saying
...
I am attempting to grab an image from a MySQL table and echo it back to a
browser like so:
<img border="1" src="./get_photo.php?image_id=<? echo $image_id;
?>">
However, All I get is broken links. I think I am just not understanding how
all the Image functions need to line up. I do have GD compiled into PHP.
I have pasted two get_photo.php versions below. The first one works, but
does not create thumbnail images. The second one creates the broken images.
I have been trying to get this to work for quite a while now, so any help
would be appreciated.
<----------------- Begin Code for WORKING NON-THUMBNAIL get_photo.php
----------------------------------->
if( $image_id ) <?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:office:office" />
{
$sql = "SELECT image_bin_data, image_filetype from IMAGES where
image_id=$image_id";
$result = db_query ( $sql );
$record = db_fetch_object ( $result );
$type = $record->image_filetype;
$image = $record->image_bin_data;
Header( "Content-type: $type");
echo $image;
};
<----------------- End Code for WORKING NON-THUMBNAIL get_photo.php
----------------------------------->
<----------------- Begin Code for NON-WORKING THUMBNAIL get_photo.php
----------------------------------->
<?
include ( "./includes/common/common.php" );
if( $image_id )
{
$sql="SELECT image_bin_data, image_filetype from IMAGES where
image_id=$image_id";
$result=db_query ( $sql );
$record=db_fetch_object ( $result );
$type=$record->image_filetype;
$image=$record->image_bin_data;
$new_w=75;
$new_h=75;
Header("Content-type: $type");
$dst_img=ImageCreate($new_w, $new_h);
$src_img=ImageCreateFromGif($image);
ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),I
mageSY($src_img));
imageGif($dst_img);
echo $src_img;
imagedestroy($dst_img);
imagedestroy($src_img);
}
?>
<----------------- End Code for NON-WORKING THUMBNAIL get_photo.php
----------------------------------->