<?
 if($idf) {
    require ("open_db_prod.php" );

    $query = "SELECT Imagen, filetype FROM productos WHERE id=".$idf;
    $res = mysql_query($query, $conexion_prod) or die("ERROR BUSCANDO IMAGEN");

	    $data = mysql_result($res,0,'Imagen');
	    $type = mysql_result($res,0,'filetype');
	    mysql_free_result($res);
	    mysql_close($conexion);
    if ( !empty( $type) )
    {
	    Header( "Content-type: $type" );
	    echo $data;
    } else {
	    Header("Content-type: image/gif"); 

	    $fp = fopen("images/simagen.gif","rb"); 
	    $file = fread($fp,filesize("images/simagen.gif")); 
	    fclose($fp); 

	    echo $file;   
    }
  } else {
   echo "<META CONTENT=\"0; URL=error.htm\" HTTP-EQUIV=\"REFRESH\">";
  }
?> 