MySQL in a for loop



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();

}

--------------------------------------------------------------------------------------------------------------------------------------------------------

.



Relevant Pages

  • Re: [PHP] Newbie question, Which way is best?
    ... I have a script that contains a form and a pagination routine that calls ... I want to pass an sql query along with some other variables to the ... problems successfully passing the SQL query string within the url. ...
    (php.general)
  • Re: Newbie trying to put SQL Query into a VBScript
    ... my script works great and I thank you for helping me ... run an SQL query on the database, rather than to have to log in to each ... I have a script that I'm making to help automate ...
    (microsoft.public.scripting.vbscript)
  • Re: MySQL in a for loop
    ... > works on it's own in separate script. ... > not connect to MySQL database on localhost\n"; ... > for my $messageID { ... > #SQL Query 1 HANDLE ...
    (perl.beginners)
  • Ezportal/Ztml v1.0 Multiple vulnerabilities
    ... Multiple Cross Site Scripting Vulnerabilities ... This can be used to post arbitrary HTML or web script code. ... This can be used make any SQL query by injecting arbitrary SQL code. ... Authentication Bypass Vulnerability ...
    (Bugtraq)
  • Instant Color Coding
    ... May I know how to develop application as like SQL Query ... Analyzer that color code the text as user enter the script without any delay. ...
    (microsoft.public.win32.programmer.ui)