next up previous contents
Next: About this document ... Up: Perl on the Web Previous: Two-way Internet Connections: the   Contents

Database Access: the DBI module

use DBI;
$dbh = DBI->connect('DBI:mysql:accounts:localhost','user','password') ||
          die("Couldn't connect to server");

$sth = $dbh->prepare('select name,balance from active where balance > 100;');
$sth->execute();

while((@row) = $sth->fetchrow()){
    print "$row[0] $row[1]\n";
}


Phil Spector 2002-10-18