patricia_e has asked for the wisdom of the Perl Monks concerning the following question:
I looked through 'Categorized Questions and Answers' and also searched this site and others, and I haven't come up with an answer.
I am trying to pluck email addresses from a mysql db to send reminder letters.
My code:The error messages I get are:#!/usr/bin/perl -w use strict; use CGI; use DBI; # Declare and initialize variables my $host = 'hostname'; my $db = 'dbname'; my $db_user = 'dbuser'; my $db_password = 'mypassword'; my $dbh = DBI->connect("dbi:mysql:$db:$host", "$db_user", "$db_passwor +d" or die "Couldn't connect: $DBI::errstr"); my $sth = $dbh->prepare("SELECT * FROM feRegistrants" or die "Couldn't + prepare SQL: $DBI::errstr"); $sth->execute or die "Couldn't execute statement: " . $sth->errstr; my @data; while (@data = $sth->fetchrow_array()) { my $email = $data[5]; my $fname = $data[2]; print "Content-type:text/html\n\n"; open(MAIL, "|/usr/lib/sendmail -t -n") || die "Unable to open sendmail +"; print MAIL "To: $email \nFrom: the server\n"; print MAIL "Subject: Subject\n"; print MAIL<<EOF; Dear $fname,\n You have registered for *** workshop on the *** of ****, 2005. Please +let us know if you are unable to attend by emailing us at *** or call +ing us at ***. We look forward to working with you. EOF close(MAIL); } $dbh->disconnect();
Any suggestions?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: no database driver specified and DBI_DSN env var not set
by ambrus (Abbot) on Jan 03, 2005 at 22:05 UTC | |
|
Re: no database driver specified and DBI_DSN env var not set
by injunjoel (Priest) on Jan 03, 2005 at 22:06 UTC | |
|
Re: no database driver specified and DBI_DSN env var not set
by runrig (Abbot) on Jan 04, 2005 at 00:25 UTC |