I'm having a pretty basic issue. I do PHP and am Perl has always been pretty awkward 
for me. I'm successfully querying from my mySQL database. I'm also successfully 
looping through the returned results. My problem is with the IF statement in the 
loop.... The if ($html < 1)  part. $html is a column name fromteh database and I just 
need it to chack if it's 1 or 0 and send the appropriate email to the address 
currently in the loop. I'm sure the problem is that I'm jsut not referencing the $html 
column value correctly. 
Thanks in advance your assistance.


my $dbh = DBI->connect($dsn, $db_user_name, $db_password);

my $sth = $dbh->prepare(qq{
    SELECT email, html FROM user WHERE newsletter > 0
    
});
$sth->execute();

while (my ($email) = 
    $sth->fetchrow_array()) 
{
open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";

if ($html < 1) {

print SENDMAIL "To: $email \n";
print SENDMAIL "From: $reply_to\n";
print SENDMAIL "Subject: $subject\n";
print SENDMAIL "Content-type: text/plain\n\n";
print SENDMAIL "$content_plain";
close(SENDMAIL);

} else {
print SENDMAIL "To: $email \n";
print SENDMAIL "From: $reply_to\n";
print SENDMAIL "Subject: $subject\n";
print SENDMAIL "Content-type: text/html\n\n";
print SENDMAIL "$content_html";
close(SENDMAIL);
}

}

Thanks,

Jeff

Reply via email to