Gossamer Forum
Home : Products : DBMan : Customization :

Alex, help me -- '$sth->fetchrow_array'?

Quote Reply
Alex, help me -- '$sth->fetchrow_array'?
I want to make an admin_email mode in dbman SQL.
To do it I should get the email lists from the Items_users table.
I think it is concerned with '$sth->fetchrow_array'. Is it?
But I dont know exactly what should I do.
Can you, and everybody, help me?
Quote Reply
Re: Alex, help me -- '$sth->fetchrow_array'? In reply to
$sth->fetchrow_array contains the data from a database query, and you would do a query on the table where you have the email address stored.
If you want help on the query, let me know. I'm sure someone else can help you with the bulk mail part.
Quote Reply
Re: Alex, help me -- '$sth->fetchrow_array'? In reply to
You can try modifying the Mass Mailer script in the Resource Center or use the Web Mailer script I wrote, which is located:

www.anthrotech.com/cgi/dbman/mods/webmailer/webmailer.exe

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
* Check Resource Center
* Search Forums
Quote Reply
Re: Alex, help me -- '$sth->fetchrow_array'? In reply to
I'm modifying the Mass Mailer script in the Resource Center.
It uses push function to get email list.
Below is the script.

LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE;
}
if ($line =~ /^#/) { next LINE;
}
chomp ($line);
@data = split (/\|/, $line);
push(@email_list,$data[12]);
}
foreach $email (@email_list) {
open (MAIL, "$mailprog") or &cgierr("Can't open...");
print MAIL "To: $email\n";
.....
}

Now I'm trying to get the list in dbman sql.
web dog and AnthroRules, do you know the way?

Quote Reply
Re: Alex, help me -- '$sth->fetchrow_array'? In reply to
Well,

Your database email address is in the Items_users table ? If the field is called Email, then try this :-

$query = qq!
SELECT Email FROM $db_table_user
!;
$sth = $DBH->prepare ($query) or &cgierr ("Unable to query db:$DBI::errstr");
$sth->execute or &cgierr ("Unable to exec: $DBI::errstr");
if ($sth->rows) {
while (@tmp = $sth->fetchrow_array) {
push (@email_list, @tmp) ;
}
else {
&cgierr ("Couldn't find the info in the requested table!!");
}
foreach $email (@email_list) {
open (MAIL, "$mailprog") or &cgierr("Can't open...");
print MAIL "To: $email\n";
.....
}

Quote Reply
Re: Alex, help me -- '$sth->fetchrow_array'? In reply to
web dog, yours is the answer.
I met some error. But after changing a little, a good bulk mail script was born.
You are my Jusus.
Thanks.
(I'm using the following source)

$query = qq!
SELECT email FROM $db_table_user
!;
$sth = $DBH->prepare ($query) or &cgierr ("Unable to query db:$DBI::errstr");
$sth->execute or &cgierr ("Unable to exec: $DBI::errstr");
if ($sth->rows) {
while (@tmp = $sth->fetchrow_array) {
push (@email_list, @tmp) ;
foreach $email (@email_list) {
open (MAIL, "$emailprog") or &cgierr("Can't open...");
print MAIL "To: $email\n";
print MAIL "From: $admin_email\n";
print MAIL "Subject: $in{'subject'}\n\n";
print MAIL "-" x 75 . "\n\n";
print MAIL $in{'emailmessage'};
close (MAIL);
}

}
Quote Reply
Re: Alex, help me -- '$sth->fetchrow_array'? In reply to
Great !!

Glad it works for you.