in reply to Images

I find the qq{} operation to be very helpful when using perl and html at the same time. Here's an example that should be very easy for you to implement:
#!/usr/bin/perl -w use DBI; use CGI; print "Content-type: text/html\n\n"; $filename = "./test.png"; $html = qq{<html><body>}; $html .= qq{<img src="$filename" width="300" height="300">}; print $html;
I believe all that should work for ya! Enjoy! :-)

Replies are listed 'Best First'.
Images
by Anonymous Monk on Oct 25, 2002 at 10:31 UTC
    Hi, Thanks for your kind response. I've changed my code.but still ....can't get it. my new code is aas follows...
    #!/usr/bin/perl use strict; use DBI; my ($user,$password,$sno,$name,$datasource,$h); $user="mydb1"; $password="mydb1"; print "Content-type:text/html\n\n"; my $h = qq{<html><body>}; my $dbh = DBI->connect("dbi:mysql:mydb", $user, $password) or die "Can +'t connect to "; my $sth = $dbh->prepare( q{SELECT sno, name FROM IMAGE}) or die "Can't + prepare statement: $DBI::errstr"; my $rc = $sth->execute or die "Can't execute statement: $DBI::errstr +"; while ( my($sno, $name) = $sth->fetchrow() ) { $h .= qq{$name}; } $sth->finish; print $h; print "</body></html>\n"; $dbh->disconnect;
    The images are not appearing .

    Edit kudra, 2002-10-27 Added code tags

      #!/usr/bin/perl use strict; use DBI; my ($user,$password,$sno,$name,$datasource,$h); $user="mydb1"; $password="mydb1"; print "Content-type:text/html\n\n"; my $h = qq{<html><body>}; my $dbh = DBI->connect("dbi:mysql:mydb", $user, $password) or die "Can +'t connect to "; my $sth = $dbh->prepare( q{SELECT sno, name FROM IMAGE}) or die "Can't + prepare statement: $DBI::errstr"; my $rc = $sth->execute or die "Can't execute statement: $DBI::errstr"; + while ( my($sno, $name) = $sth->fetchrow() ) { $h .= qq{$name}; } $sth->finish; print $h; print "</body></html>\n"; $dbh->disconnect;
      The $name part should be more like this:
      $h .= qq{<img src="$name" width="300" height="300">};
      The print $h part is displaying the data in $h, but this data must be in html format, meaning that you need html code for the images to show up. Good luck! donniejones18

      Edit kudra, 2002-10-27 Added line breaks within code