Hello,
I am a newbie on Perl. I am creating a site for our bookshop where the details (ISBN, Title, Cost, Book cover Image) of the books that we are selling can be viewed online.
The book records are held in an Access Database. I have managed to display the records for all text fields, but the 'Image' field (OLE Object - a jpeg image of the front cover embedded in the db) I can't get to display. Can you help me??
I have read many help pages on the web and some say to code the following line and then output the image i.e.
But when I do this all I get is the words "Content-type: image/jpeg" displayed on the screen.
My script is below - can anybody help???
The Image field is not displayed. What am I doing wrong??
Many thanks,
Catherine
I am a newbie on Perl. I am creating a site for our bookshop where the details (ISBN, Title, Cost, Book cover Image) of the books that we are selling can be viewed online.
The book records are held in an Access Database. I have managed to display the records for all text fields, but the 'Image' field (OLE Object - a jpeg image of the front cover embedded in the db) I can't get to display. Can you help me??
I have read many help pages on the web and some say to code the following line and then output the image i.e.
Code:
print "Content-type: image/jpeg\n\n";
print $Data{'Image'};
But when I do this all I get is the words "Content-type: image/jpeg" displayed on the screen.
My script is below - can anybody help???
Code:
<%@ Language=PerlScript %>
<%
use strict;
use Win32::ODBC;
use vars qw($Request $Response $Application $Session);
use lib $Request->ServerVariables("APPL_PHYSICAL_PATH")->Item . "\\dandy";
use FreezeThaw qw(freeze thaw);
use CGI ":standard";
%>
<!--#include virtual="include/PerlAsp.inc"-->
<!--#include virtual="include/PerlAspTable.inc"-->
<!--#include file="Bookshop.inc"-->
<%
my $db = DandyDb(); #open database connection...
if (not ref $db)
{
# if no database - show the error message
print(h1("Error"), p(strong("Database not
available"), " - ", $db), "\n");
$Response->flush();
}
else # Get records from Bookshop Table and display in a
# table on the webpage
{
my $Bkshop = DandyTable("Bookshop");
my $data;
my $sql = "SELECT $Bkshop.ISBN, Title, Cost, Image FROM
$Bkshop;
if ($db->Sql($sql))
{
print p(strong("Database Error:"),br,scalar
($db->Error));
$Response->flush();
}
else
{
%>
<table>
<tr>
<td>ISBN</td>
<td>Title</td>
<td>Price</td>
<td>Image</td>
</tr>
</table>
<table>
<tr>
<%
while ($db -> FetchRow())
{
my %Data = $db->DataHash();
print "<td> $Data{'ISBN'}</td>";
print "<td> $Data{'Title'}</td>";
#Format Price field to 2d. places
my $price = $Data{'Cost'};
$price = sprintf('%0.2f', $price);
print "<td> £$price</td>";
#This is where I want to display the image -
#but it doesn't work.
print "<td> $Data{'Image'} </td></tr>";
}
print "</table>";
}
}
$db->Close() if ref($db);
undef($db);
%>
</body>
</html>
The Image field is not displayed. What am I doing wrong??
Many thanks,
Catherine