Submit Your Article Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read


Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Share Thread: & Tags

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-10-2004, 07:50 AM
WebProWorld Member
 
Join Date: Jan 2004
Location: Bangladesh
Posts: 25
Informer45 RepRank 0
Default image retrieval from database not working?

my prob.:iam getting image from database
but not able to convert that image(resize taht is).
Warning: getimagesize: Unable to open 'ÿØÿá›Exif' for reading. in c:\apache\htdocs\upload\sho1.php on line 19

my php code:
/ database connection
$conn = mysql_connect("localhost") OR DIE (mysql_error());
@mysql_select_db ("beebaho", $conn) OR DIE (mysql_error());
$sql = "SELECT * FROM images WHERE Id=4";
$result = mysql_query ($sql, $conn);
if (mysql_num_rows ($result)>0) {
$row = @mysql_fetch_array ($result);
$image_type = $row["image_type"];
global $maxH,$maxW,$image,$imgInfo,$imgwidth,$imgheight;
$image = $row["pic"];

// echo $image;

$imgInfo= getimagesize($image);

$imgwidth = $imgInfo[0];
$imgheight = $imgInfo[1];
$maxW=200;
$maxH=300;
if ($imgwidth > $maxW) {
$ration = $maxW/$imgwidth;
$newwidth = round($imgwidth*$ration);
$newheight = round($imgheight*$ration);
if ($newheight > $maxH) {
$ration = $maxH/$newheight;
$newwidth = round($newwidth*$ration);
$newheight = round($newheight*$ration);
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
} else {
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
}
} else if ($imgheight > $maxH) {
$ration = $maxH/$imgheight;
$newwidth = round($imgwidth*$ration);
$newheight = round($imgheight*$ration);
if ($newwidth > $maxW) {
$ration = $maxW/$newwidth;
$newwidth = round($newwidth*$ration);
$newheight = round($newheight*$ration);
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
} else {
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
}
} else {
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
}



// Header ("Content-type: $image_type");
echo $image;
}
?>


if comment "$imgInfo= getimagesize($image);"
and "echo $image;"
then it works but image is very large
__________________
The impossible doesnot Exist!
Reply With Quote
  #2 (permalink)  
Old 12-18-2004, 01:05 PM
Deep13's Avatar
WebProWorld Veteran
 
Join Date: Dec 2003
Location: India
Posts: 304
Deep13 RepRank 0
Default

I hope the image path you have specified in the database match with the actually path of the image..

and 2nd thing...

in that warning..why it is not displaying the image ext? are u stroing image name without ext or something?

Deep
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:27 AM.



Search Engine Optimization by vBSEO 3.3.0