Have you evaluated exactly what your split is handing you and also exactly what is in the database? You say maybe a 10th of the time you don't see the result you expect. Could this be due to rogue characters introduced in your db or file data. Since what you are printing when you don't find a match would probably satisfy file input try dumping your database and evaluate the data there. Your logic in processing seems sound enough. I think the data may be your variant here.

Ian

Rob wrote:

What I'm experiencing is that, maybe a 10th of the time it will give me a
name that's in both; most of the time it will appear as if the name isn't
in the database but if I check in by hand the name really is there.

Is this the line thats the problem? $userD = $sql->fetchrow_array();
I've tried it like this but no change ($userD) = $sql->fetchrow_array();

Any ideas on what would work?

--
Rob

Do not meddle in the affairs of wizards,
for they are subtle and quick to anger.

On Thu, 27 Mar 2003, Tim Bunce wrote:



On Thu, Mar 27, 2003 at 01:53:16PM -0500, [EMAIL PROTECTED] wrote:


$sql->fetch_rowarray() returns a LIST. You are capturing the count of that list.


Actully fetch_rowarray() returns just the first element when
called in a scalar context.

Perhaps the problem is that the statement returns more than
one row but only one is being fetched.

Tim.



-----Original Message-----
From: Rob [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 27, 2003 1:12 PM
To: [EMAIL PROTECTED]
Subject: db to passwd comparison

Hi, I'm trying to find out which users in a passwd file are not in a
database.  What I've tried so far(see below) finds a few but misses even
more.  I'm thinking it might be the way I'm preparing the statement or
perhaps executing it?  Something else all together?  Any help appreciated.

<snip>
$sql = $dbh->prepare_cached("SELECT CustNo, UserName FROM call_log WHERE
   UserName = ?");

open(IN, "passwd") || die "Can't open passwd file:$!\n";
open(OUT, ">usernames.db") || die "Can't create output file:$!\n";
while(<IN>) {
   chomp;
   ($userP, $group) = (split /:/)[0,3];
   $grps{$group}++;
   $sql->execute($userP)
           or warn "Can't execute select " . $sql->errstr;
   $userD = $sql->fetchrow_array();
   if($userD eq "") {
       print OUT "UserP:$userP - UserD:$userD\n";
   }
   $sql->finish;
}
close(OUT);
close(IN);
</snip>

Thanks,
--
Rob










Reply via email to