Index: trunk/DNSDB.pm
===================================================================
--- trunk/DNSDB.pm	(revision 156)
+++ trunk/DNSDB.pm	(revision 157)
@@ -1479,4 +1479,8 @@
 ##todo:  immediate, secondary, full (default)
 
+  # Return false on invalid types
+  return 0 if !grep /^$type1$/, ('record','defrec','user','domain','group');
+  return 0 if !grep /^$type2$/, ('record','defrec','user','domain','group');
+
   # Return false on impossible relations
   return 0 if $type1 eq 'record';	# nothing may be a child of a record
@@ -1499,7 +1503,11 @@
     my $sql = "SELECT $par_col{$type} FROM $par_tbl{$type} WHERE $id_col{$type} = ?";
     my $result = $dbh->selectrow_hashref($sql,
-	undef, ($id) ) or warn $dbh->errstr." $sql";
-    if ($result->{$par_col{$type}} == $id1) {
+	undef, ($id) );
+    if ($result && $result->{$par_col{$type}} == $id1) {
       $foundparent = 1;
+      last;
+    } else {
+##fixme: do we care about trying to return a "no such record/domain/user/group" error?
+      warn $dbh->errstr." $sql, $id" if $dbh->errstr;
       last;
     }
