Roger Ramjet wrote:Don't store the image in the database, just the filename. Pointless havinf tyo extract the binary data to a file every time.
hey thanks for the reply.
Here is the situation. I was given a sql backup from mysql. For the avatar images stored in the DB by vbulletin. Thing is the site where the sql file came from was hacked and they are trying to get all there data migrated over to phpbb. Now they have everything except for the avatar images. Now I am trying to extract the images from the DB but im not having any luck.
Ive tryed this:
<?
if($id) {
// you may have to modify login information for your database server:
@MYSQL_CONNECT("localhost","root","");
@mysql_select_db("vbulletin_db");
$query = "SELECT * FROM customavatar where userid=$id";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"avatardata");
$type = explode(".",@MYSQL_RESULT($result,0,"filename"));
//echo $type[1];
//return;
switch ($type[1]) {
case "gif":
$type2 = "image/gif";
break;
case "jpg":
$type2 = "image/jpg";
break;
case "GIF":
$type2 = "image/gif";
break;
case "JPG":
$type2 = "image/jpg";
break;
}
header( "Content-type: $type2");
echo $data;
};
?>
now it works, but the image comes up blank. If I right click the image and view properties, the file size, width, height and filename are displayed.
example:

now im not sure but the avatardata field in the DB is a "longtext" shouldnt this be longblob?
if it was changed from blob to text will the data be currupted?