OK - if you can put your code in <CODE> tags, it's a bit easier to read, like this:
#!/usr/bin/perl
use DBI;
$user="mydb1";
$password="mydb1";
print "Content-type:text/html\n\n";
my $dbh = DBI->connect("dbi:mysql:mydb", $user, $password) or die "Can
+'t connect to $data_source: $DBI::errstr";
print "successful connection\n";
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";
print "Query will return $sth->{NUM_OF_FIELDS} fields.\n\n";
print "Field names: @{ $sth->{NAME} }\n";
while (($sno, $name) = $sth->fetchrow_array) {
print "$name: $phone\n";
$line="<img src=".$name;
$line=$line." >";
print "<img src=\"$line\">";
}
$dbh->disconnect;
print "succefully disconnected\n";
print "</body></html>\n";
OK, so looking at the code, here's my thoughts:
- first of all, I'm going to repeat this - get used to CGI.pm, it'll make your life a lot easier.
- use strict - will catch a lot of errors, such as no definition of $phone
- You've got no <body> tag.
- There's no <P> tags surrounding your text
- You're generating HTML that looks something like <img src="<img src="filename">"> in the while loop
Hey, if there's code up ^^ there ^^, don't blame me if it doesn't work.
But today you took me walking, Through a land that we have lost,
While our children sit at websites, With no access to the cost