sub write_sub { my $vars = shift; my $errorcode = shift; if (&get_errorlevel) {return} # don't write anything to the database if something's errored out on us. my $dbh = DBI->connect("DBI:CSV:f_dir=c:/journal/"); my $sth = $dbh->prepare ("SELECT id FROM entries") || die "$! and $DBI::errstr"; $sth->execute; my $maxid; while (my $thisrow = $sth->fetchrow_arrayref) { if ($$thisrow[0] > $maxid) {$maxid = $$thisrow[0]} }; $maxid++; my $title = $dbh->quote ($$$vars{params}{title}); my $date = $dbh->quote (scalar localtime); my $entry = $dbh->quote (unpack ("H*",$$$vars{params}{entry})); # Hi, Tye! $sth = $dbh->prepare ("INSERT INTO entries (id, date, title, entry) VALUES ($maxid, $date,$title, $entry)")|| die "$! and $DBI::errstr"; $sth->execute; }