#!/usr/bin/perl -w
print "Content-type: text/html\n\n";
use DBI;
my $host = "localhost";
my $usr = "root";
my $pwd = "";
my $dbname = "test";
my $DBH = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, {
AutoCommit => 0,
RaiseError => 1,
}) or die $DBI::errstr;
my $sth = $DBH->prepare('
SELECT DISTINCT AGE
FROM USERS
WHERE NAMES = ?');
$sth->execute('John');
my $records = $sth->fetchall_arrayref;
for my $record (@$records){
print $rest = $record->[0];
}
print "Content-type: text/html\n\n";
print <
Untitled Document
Age list
$rest
START_HTML