Index: trunk/cgi-bin/main.cgi
===================================================================
--- trunk/cgi-bin/main.cgi	(revision 161)
+++ trunk/cgi-bin/main.cgi	(revision 166)
@@ -799,8 +799,8 @@
     if ($base =~ /^[ds]$/) {
       $sql = "select * from poolips where available='y' and".
-	" ptype='$base' and (city='Sudbury' or city='North Bay')";
+	" type='$webvar{alloctype}' and (city='Sudbury' or city='North Bay')";
     } else {
       $sql = "select * from poolips where available='y' and".
-	" ptype='$base' and city='$webvar{pop}'";
+	" type='$webvar{alloctype}' and city='$webvar{pop}'";
     }
 
@@ -1040,5 +1040,5 @@
   # because I'm lazy, we'll try to make the SELECT's bring out identical)ish) data
   if ($webvar{block} =~ /\/32$/) {
-    $sql = "select ip,custid,ptype,city,circuitid,description,notes from poolips where ip='$webvar{block}'";
+    $sql = "select ip,custid,type,city,circuitid,description,notes from poolips where ip='$webvar{block}'";
   } else {
     $sql = "select cidr,custid,type,city,circuitid,description,notes from allocations where cidr='$webvar{block}'"
@@ -1134,8 +1134,9 @@
   };
   if ($@) {
-    carp "Transaction aborted because $@";
+    my $msg = $@;
+    carp "Transaction aborted because $msg";
     eval { $ip_dbh->rollback; };
-    syslog "err", "$authuser could not update block/IP '$webvar{block}': '$@'";
-    printError("Could not update block/IP $webvar{block}: $@");
+    syslog "err", "$authuser could not update block/IP '$webvar{block}': '$msg'";
+    printError("Could not update block/IP $webvar{block}: $msg");
     return;
   }
@@ -1209,5 +1210,5 @@
 
     # Unassigning a static IP
-    my $sth = $ip_dbh->prepare("select ip,custid,city,ptype,notes,circuitid from poolips".
+    my $sth = $ip_dbh->prepare("select ip,custid,city,type,notes,circuitid from poolips".
 	" where ip='$webvar{block}'");
     $sth->execute();
@@ -1216,6 +1217,4 @@
     $sth->bind_columns(\$cidr, \$custid, \$city, \$alloctype, \$notes, \$circid);
     $sth->fetch() || croak $sth->errstr;
-
-    $alloctype .="i";
 
   } else { # done with alloctype=~ /^.i$/
