Calculating password length with DBM : DBM « MySQL Database « PHP






Calculating password length with DBM

 
<?php
$data_file = '/tmp/users.db';
$total_length = 0;
if (! ($dbh = dba_open($data_file,'r','gdbm'))) {
    die("Can't open database $data_file");
}

$k = dba_firstkey($dbh);
while ($k) {
    $total_length += strlen(dba_fetch($k,$dbh));
    $k = dba_nextkey($dbh);
}

print "Total length of all passwords is $total_length characters.";

dba_close($dbh);
?>
  
  








Related examples in the same category

1.Storing structured data in a DBM database
2.Tracking users and passwords with a DBM database