Hi Guys,
Can you please look at the below script. The SQL query
works on it's own in separate script. But not when it is put into the
"for" loop in this script
. Any ideas??
Thanks,
David
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl -w
#Reduce scripting errors
use strict;
#Call relevant modules
use Net::POP3;
use DBI;
#Connect to POP3 server
my $pop3server = Net::POP3->new('****server****');
#Login to POP3 server
$pop3server->login('****user****', '****pass****');
#How many messages there is
my $lastm = ($pop3server->popstat)[0];
#Connect to MySQL database on localhost
my $MySQL = DBI->connect
("DBI:mysql:NOD32:localhost","****","***************") or die " Could
not connect to MySQL database on localhost\n";
#Get and process mail
for my $messageID (90){
my $MFH = $pop3server->getfh($messageID);
#Extract values
my $name = '';
my $refno = '';
my $userpass = '';
my $wtable = '';
while(<$MFH>) { if ( $_ =~ m/UserName:Password=/ ) {(undef, $userpass) =
split /=/, $_;}
if ( $_ =~ m/person:/ ) {(undef, $refno) = split /:/, $_;}
if ( $_ =~ m/Clients_name:/ ) {(undef, $name) = split /:/, $_;}
}
if($refno =~ /NRS/) {$wtable = 'RSorders2005';} else{ $wtable =
'SUorders2005';};
chomp($userpass);
$MySQL->quote($userpass);
$refno =~ s/^\s//;
#SQL Query 1
my $SQLQ1a = "UPDATE $wtable SET UsernamePassword = '$userpass' WHERE
RefNo = '$refno'";
print "$SQLQ1a";
#SQL Query 1 HANDLE
my $SQLQ1 = $MySQL->prepare($SQLQ1a);
#Exexute SQL Query 1
$SQLQ1->execute();
}
--------------------------------------------------------------------------------------------------------------------------------------------------------
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>