#!/usr/local/bin/perl # # MySQL perl test CGI program # # Name: Matthew W. Coan # Date: Thu May 12 02:22:52 EST 2011 # print "Content-type: text/html\r\n\r\n"; flush; use DBI; $dbh = DBI->connect('DBI:mysql:test', 'root', 'l0vey0u') || die "Could not connect to database: $DBI::errstr"; $sth = $dbh->prepare('SELECT NAME,AGE FROM PERSON ORDER BY AGE'); $sth->execute(); print "DBI TEST\n"; print "\n"; print "\n"; while($result = $sth->fetchrow_hashref()) { print "\n"; } print "
NAMEAGE
$result->{NAME}$result->{AGE}
\n"; print "\n"; $dbh->disconnect();