#!/usr/bin/perl -w use strict; use DBI; use CGI::Carp qw(fatalsToBrowser); use CGI qw (:standard); print "Content-type: text/html\n\n"; my $dbh = DBI->connect(qq{DBI:mysql:database=subscriptions;host=localhost,I DON'T HAVE A USERNAME AND PASSWORD OTHER THAN ROOT}, {RaiseError => 1} ); my $sth = $dbh->prepare( q{SELECT email FROM contacts WHERE state = ?} ); $sth->execute('OH') or die $sth->errstr; while (my @result = $sth->fetchrow_array()) { print "@result\n"; } # check for problems which may have terminated the fetch early die $sth->errstr if $sth->err; $dbh->disconnect;