MySQL in a for loop
- From: david@xxxxxxxxx (David Foley)
- Date: Wed, 27 Jul 2005 14:17:03 +0100
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();
}
--------------------------------------------------------------------------------------------------------------------------------------------------------
.
- Follow-Ups:
- Re: MySQL in a for loop
- From: David Van Ginneken
- Re: MySQL in a for loop
- Prev by Date: Help: automated email forwarding similar to .forward
- Next by Date: Trying to scape data out of HTML
- Previous by thread: Help: automated email forwarding similar to .forward
- Next by thread: Re: MySQL in a for loop
- Index(es):
Relevant Pages
|