any ideas? thanks.
[perl]
# data into db, and close connection
my $query = "SELECT urldb FROM keycheck WHERE urldb = \"$urldb\"" or return 0;
my @rows = $dbh->do($query);
if (@rows) {
foreach $row (@rows) { if($row == $urldb) {$dbh->disconnect; } $row++; }
#else { #if its not there, put it there
$statement = "INSERT INTO keycheck VALUES (?, ?, ?, ?)";
$sth = $dbh->prepare($statement) ¦¦ die $dbh->errstr;
$sth->execute("", "", $urldb, $title) ¦¦ die $dbh->errstr; }
}
$dbh->disconnect; #else this just goes away after writing once which is no good.[/perl]
here is the new and improved code:
[perl]
# data into db, and close connection
my $query = "SELECT urldb FROM keycheck WHERE urldb = \"$urldb\"" or return 0;
my $rows = $dbh->do($query);
if ($rows == 0) {
#foreach $row (@rows) { if($row eq $urldb) {$dbh->disconnect; } $row++; }
#else { #if its not there, put it there
$statement = "INSERT INTO keycheck VALUES (?, ?, ?, ?)";
$sth = $dbh->prepare($statement) ¦¦ die $dbh->errstr;
$sth->execute("", time(), $urldb, $title) ¦¦ die $dbh->errstr; }
[/perl]
but wait, there's more! I also needed to make sure the urls in the db weren't in there as domain.com/ and domain.com, so I added this:
[perl]$urldb = $q->param('url');
$urldb =~ s/\/$//; #chop the trailing slash if no page name.
[/perl]