Index: /trunk/ippMonitor/configure.tcsh
===================================================================
--- /trunk/ippMonitor/configure.tcsh	(revision 39497)
+++ /trunk/ippMonitor/configure.tcsh	(revision 39498)
@@ -227,4 +227,6 @@
 
 Fine tuning of the installation directories:
+  --useMDB2              use MDB2 interface instead of DB
+
   --bindir=DIR           user executables [PREFIX/bin/$ARCH] 
   --libdir=DIR           object code libraries [PREFIX/lib/$ARCH]
Index: /trunk/ippMonitor/def/autocode.php
===================================================================
--- /trunk/ippMonitor/def/autocode.php	(revision 39497)
+++ /trunk/ippMonitor/def/autocode.php	(revision 39498)
@@ -26,4 +26,5 @@
 
 // define restrictions to the queries
+$WHERE = "";
 // ** TABLE RESTRICTIONS **
 
@@ -40,8 +41,8 @@
 
 // get the result table count
-if ($MODE == "basic") {
+if ("$MODE" == "basic") {
   $sql = "SELECT count(*) FROM $TABLE $WHERE";
 }
-if ($MODE == "summary") {
+if ("$MODE" == "summary") {
   $sql = "SELECT count(*) FROM (SELECT $FIELDS FROM $TABLE $WHERE) as TEMP";
 }
@@ -53,5 +54,5 @@
   menu_end();
 }
-if (!$qry->fetchInto($row)) {
+if (!dbFetchInto($qry, $row)) {
   echo "<b>error reading $TABLE table count</b><br>\n";
   echo "<br><small><b> count query : $sql </b></small><br>\n";
@@ -78,8 +79,8 @@
 
 // query the database
-if ($MODE == "basic") {
+if ("$MODE" == "basic") {
   $sql = "SELECT $FIELDS FROM $TABLE $WHERE LIMIT $dTABLE OFFSET $rowStart";
 }
-if ($MODE == "summary") {
+if ("$MODE" == "summary") {
   $sql = "SELECT $FIELDS FROM $TABLE $WHERE LIMIT $dTABLE OFFSET $rowStart";
 }
@@ -94,4 +95,5 @@
 // ** HEAD CODE **
 
+$buttonLink = "";
 // ** BUTTON RESTRICTIONS **
 navigate_buttons ($rowStart, $rowLast, $dTABLE, $rowTotal, $buttonLink, $ID, '$FILE');
@@ -113,5 +115,5 @@
 
 // list the results
-while ($qry->fetchInto($row)) {
+while (dbFetchInto($qry, $row)) {
   // $link = "$FILE" . "?expID=" . $row[0] . "&" . $ID['link'];
 
Index: /trunk/ippMonitor/def/autocodeImage.php
===================================================================
--- /trunk/ippMonitor/def/autocodeImage.php	(revision 39497)
+++ /trunk/ippMonitor/def/autocodeImage.php	(revision 39498)
@@ -46,5 +46,5 @@
   menu_end();
 }
-if (!$qry->fetchInto($row)) {
+if (!dbFetchInto($qry, $row)) {
   echo "<b>error reading $TABLE table count</b><br>\n";
   echo "<br><small><b> count query : $sql </b></small><br>\n";
@@ -111,5 +111,5 @@
 
 // output the results to tmpfile
-while ($qry->fetchInto($row)) {
+while (dbFetchInto($qry, $row)) {
   $line = "";
   foreach ($row as $i => $value) {
Index: /trunk/ippMonitor/def/detInputExp.d
===================================================================
--- /trunk/ippMonitor/def/detInputExp.d	(revision 39497)
+++ /trunk/ippMonitor/def/detInputExp.d	(revision 39498)
@@ -38,6 +38,6 @@
 FIELD rawExp.bg_stdev,        5, %.2f,   stdev    
 FIELD rawExp.bg_mean_stdev,   5, %.2f,   &lt;backgnd&gt;
-FIELD *,                      5, %s,     choose,     value=resid, detResidImfile.php,     ARG2
-FIELD *,                      5, %s,     choose,     value=proc,  detProcessedImfile.php, ARG3
+FIELD *,                      5, %s,     choose,     value='resid', detResidImfile.php,     ARG2
+FIELD *,                      5, %s,     choose,     value='proc',  detProcessedImfile.php, ARG3
 
 TD_CLASS det_off  $detInputExp.include == 0
Index: /trunk/ippMonitor/def/detRun.d
===================================================================
--- /trunk/ippMonitor/def/detRun.d	(revision 39497)
+++ /trunk/ippMonitor/def/detRun.d	(revision 39498)
@@ -23,10 +23,10 @@
 FIELD det_type,     12, %s,     type
 FIELD state,         5, %s,     state
-FIELD *,             5, %s,     IN,          value=IN,   detInputExp.php,          ARG2
-FIELD *,             5, %s,     P,           value=P,   detProcessedExp.php,      ARG3
-FIELD *,             5, %s,     D,           value=D,   detResidExp.php,          ARG4
-FIELD *,             5, %s,     S,           value=S,   detStackedImfile.php,     ARG5
-FIELD *,             5, %s,     N,           value=N,   detNormalizedImfile.php,  ARG6
-FIELD *,             5, %s,     R,           value=R,   detRegisteredImfile.php,  ARG7
+FIELD *,             5, %s,     IN,          value='IN',  detInputExp.php,          ARG2
+FIELD *,             5, %s,     P,           value='P',   detProcessedExp.php,      ARG3
+FIELD *,             5, %s,     D,           value='D',   detResidExp.php,          ARG4
+FIELD *,             5, %s,     S,           value='S',   detStackedImfile.php,     ARG5
+FIELD *,             5, %s,     N,           value='N',   detNormalizedImfile.php,  ARG6
+FIELD *,             5, %s,     R,           value='R',   detRegisteredImfile.php,  ARG7
 FIELD mode,          5, %s,     mode
 FIELD filter,        5, %s,     filter     
Index: /trunk/ippMonitor/def/detRunActive.d
===================================================================
--- /trunk/ippMonitor/def/detRunActive.d	(revision 39497)
+++ /trunk/ippMonitor/def/detRunActive.d	(revision 39498)
@@ -26,10 +26,10 @@
 FIELD det_type,     12, %s,     type
 FIELD state,         5, %s,     state
-FIELD *,             5, %s,     IN,          value=IN,   detInputExp.php,          ARG2
-FIELD *,             5, %s,     P,           value=P,   detProcessedExp.php,      ARG3
-FIELD *,             5, %s,     D,           value=D,   detResidExp.php,          ARG4
-FIELD *,             5, %s,     S,           value=S,   detStackedImfile.php,     ARG5
-FIELD *,             5, %s,     N,           value=N,   detNormalizedImfile.php,  ARG6
-FIELD *,             5, %s,     R,           value=R,   detRegisteredImfile.php,  ARG7
+FIELD *,             5, %s,     IN,          value='IN',   detInputExp.php,          ARG2
+FIELD *,             5, %s,     P,           value='P',   detProcessedExp.php,      ARG3
+FIELD *,             5, %s,     D,           value='D',   detResidExp.php,          ARG4
+FIELD *,             5, %s,     S,           value='S',   detStackedImfile.php,     ARG5
+FIELD *,             5, %s,     N,           value='N',   detNormalizedImfile.php,  ARG6
+FIELD *,             5, %s,     R,           value='R',   detRegisteredImfile.php,  ARG7
 FIELD mode,          5, %s,     mode
 FIELD filter,        5, %s,     filter     
Index: /trunk/ippMonitor/def/detRunSummary.d
===================================================================
--- /trunk/ippMonitor/def/detRunSummary.d	(revision 39497)
+++ /trunk/ippMonitor/def/detRunSummary.d	(revision 39498)
@@ -16,7 +16,7 @@
 FIELD detRunSummary.iteration,  5,  %s,     iter
 FIELD detRunSummary.accept,     4,  %s,     keep
-FIELD *,                       20,  %s,     choose,    value=input, detInputExp.php,  ARG1
-FIELD *,                       20,  %s,     choose,    value=proc,  detProcessedExp.php,      ARG3
-FIELD *,                       20,  %s,     choose,    value=resid, detResidExp.php,  ARG2
+FIELD *,                       20,  %s,     choose,    value='input', detInputExp.php,  ARG1
+FIELD *,                       20,  %s,     choose,    value='proc',  detProcessedExp.php,      ARG3
+FIELD *,                       20,  %s,     choose,    value='resid', detResidExp.php,  ARG2
 FIELD detRunSummary.bg,        20,  %s,     bg
 FIELD detRunSummary.bg_stdev,  20,  %s,     bg_stdev
Index: /trunk/ippMonitor/def/keptDetrendFrames.d
===================================================================
--- /trunk/ippMonitor/def/keptDetrendFrames.d	(revision 39497)
+++ /trunk/ippMonitor/def/keptDetrendFrames.d	(revision 39498)
@@ -28,7 +28,7 @@
 FIELD detRun.det_type,         5,    %s,     type
 FIELD detRun.state,            5,    %s,     state
-FIELD *,                       20,   %s,     choose,       value=input, detInputExp.php,          ARG2
-FIELD *,                       20,   %s,     choose,       value=proc,  detProcessedExp.php,      ARG3
-FIELD *,                       20,   %s,     choose,       value=resid, detResidExp.php,          ARG4
+FIELD *,                       20,   %s,     choose,       value='input', detInputExp.php,          ARG2
+FIELD *,                       20,   %s,     choose,       value='proc',  detProcessedExp.php,      ARG3
+FIELD *,                       20,   %s,     choose,       value='resid', detResidExp.php,          ARG4
 FIELD detRunSummary.bg,        20,   %s,     bg
 FIELD detRunSummary.bg_stdev,  20,   %s,     bg_stdev
Index: /trunk/ippMonitor/def/masterDetrendFrames.d
===================================================================
--- /trunk/ippMonitor/def/masterDetrendFrames.d	(revision 39497)
+++ /trunk/ippMonitor/def/masterDetrendFrames.d	(revision 39498)
@@ -30,8 +30,8 @@
 # FIELD detRun.mode,             5,    %s,     mode
 # FIELD detRunSummary.accept,    5,    %s,     accept
-FIELD *,                       5,    %s,     choose,       value=input, detInputExp.php,          ARG2
-FIELD *,                       5,    %s,     choose,       value=proc,  detProcessedExp.php,      ARG3
-FIELD *,                       5,    %s,     choose,       value=stack, detStackedImfile.php,  ARG5
-FIELD *,                       5,    %s,     choose,       value=resid, detResidExp.php,          ARG4
+FIELD *,                       5,    %s,     choose,       value='input', detInputExp.php,          ARG2
+FIELD *,                       5,    %s,     choose,       value='proc',  detProcessedExp.php,      ARG3
+FIELD *,                       5,    %s,     choose,       value='stack', detStackedImfile.php,  ARG5
+FIELD *,                       5,    %s,     choose,       value='resid', detResidExp.php,          ARG4
 FIELD mode,         	       5,    %s,     mode
 FIELD filter,       	      10,    %s,     filter     
Index: /trunk/ippMonitor/raw/columns_in_db.php
===================================================================
--- /trunk/ippMonitor/raw/columns_in_db.php	(revision 39497)
+++ /trunk/ippMonitor/raw/columns_in_db.php	(revision 39498)
@@ -130,5 +130,5 @@
   $line = "";
   $values = array();
-  while ($qry->fetchInto($row)) {
+  while (dbFetchInto($qry, $row)) {
     // print "[".$row[0]."]<br>\n";
     foreach ($row as $index => $value) {
Index: /trunk/ippMonitor/raw/czartool_exposures.php
===================================================================
--- /trunk/ippMonitor/raw/czartool_exposures.php	(revision 39497)
+++ /trunk/ippMonitor/raw/czartool_exposures.php	(revision 39498)
@@ -74,5 +74,5 @@
 
     $qry = $db->query($sql);
-    $qry->fetchInto($count);
+  dbFetchInto($qry, $count);
 
     if ($surveyStr == "") $surveyText = "all surveys";
@@ -154,5 +154,5 @@
 
     // loop through results in order to make html table
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         $exp_id = $row[0];
@@ -257,5 +257,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] > 0) $hash[$row[0]] = "Y";
@@ -287,5 +287,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] > 0) $hash[$row[0]] = "Y";
@@ -318,5 +318,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] > 0) $hash[$row[0]] = "Y";
@@ -350,5 +350,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] > 0) $hash[$row[0]] = $row[2];
@@ -380,5 +380,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] > 0) $hash[$row[0]] = $row[2];
@@ -408,5 +408,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] > 0) {
@@ -444,5 +444,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] > 0) $hash[$row[0]] = $row[2];
@@ -475,5 +475,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] > 0) $hash[$row[0]] = $row[2];
@@ -505,5 +505,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         $hash[$row[0]] = $row[1];
@@ -536,5 +536,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
 
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] > 0) $hash[$row[0]] = $row[2];
@@ -566,5 +566,5 @@
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
     $hash = array();
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($row[2] == 2) $hash1[$row[0]] = $row[1];
Index: /trunk/ippMonitor/raw/czartool_ipptopsps.php
===================================================================
--- /trunk/ippMonitor/raw/czartool_ipptopsps.php	(revision 39497)
+++ /trunk/ippMonitor/raw/czartool_ipptopsps.php	(revision 39498)
@@ -176,5 +176,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         $labels[] = $row[0];
@@ -367,5 +367,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    $qry->fetchInto($row);
+    dbFetchInto($qry, $row);
 
     $pending = $row[0];
@@ -400,5 +400,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    $qry->fetchInto($row);
+    dbFetchInto($qry, $row);
 
     return $row[0];
Index: /trunk/ippMonitor/raw/czartool_labels.php
===================================================================
--- /trunk/ippMonitor/raw/czartool_labels.php	(revision 39497)
+++ /trunk/ippMonitor/raw/czartool_labels.php	(revision 39498)
@@ -313,5 +313,5 @@
 
     // list the results
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         echo "<tr>";
@@ -358,12 +358,12 @@
 
     // list the results
-    while ($qry->fetchInto($expType)) {
+    while (dbFetchInto($qry, $expType)) {
 
         $sql = "SELECT COUNT(*) FROM summitExp WHERE dateobs > '$date' AND exp_type = '$expType[0]'";
         $qry2 = $projectdb->query($sql);
-        $qry2->fetchInto($summit);
+      dbFetchInto($qry2, $summit);
         $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
         $qry2 = $projectdb->query($sql);
-        $qry2->fetchInto($mhpcc);
+      dbFetchInto($qry2, $mhpcc);
 
         echo "<tr>";
@@ -397,5 +397,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         $labels[] = $row[0];
@@ -621,5 +621,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    $qry->fetchInto($row);
+    dbFetchInto($qry, $row);
 
     return $row[0];
@@ -655,5 +655,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    $qry->fetchInto($row);
+    dbFetchInto($qry, $row);
 
     return $row[0];
@@ -673,5 +673,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    $qry->fetchInto($row);
+    dbFetchInto($qry, $row);
 
     $pending = $row[0];
@@ -730,5 +730,5 @@
     $dates = ""; 
     $firstIn = true;
-    while ($qry->fetchInto($row)) {
+    while (dbFetchInto($qry, $row)) {
 
         if ($firstIn) {
@@ -887,5 +887,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    $qry->fetchInto($row);
+    dbFetchInto($qry, $row);
 
     $alive = $row[0];
@@ -906,5 +906,5 @@
     $qry = $db->query($sql);
     if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
-    $qry->fetchInto($row);
+    dbFetchInto($qry, $row);
 
     return $row[0];
@@ -947,5 +947,5 @@
     }
     $res = $dbRepl->query('SHOW SLAVE STATUS');
-    while ($res->fetchInto($row)) {
+    while (dbFetchInto($res, $row)) {
         # Have a look for Last_Errno in http://dev.mysql.com/doc/refman/5.0/en/show-slave-status.html
         $errorStatusInMySql = $row[18];
Index: /trunk/ippMonitor/raw/diskUsage.php
===================================================================
--- /trunk/ippMonitor/raw/diskUsage.php	(revision 39497)
+++ /trunk/ippMonitor/raw/diskUsage.php	(revision 39498)
@@ -90,5 +90,5 @@
 
   // list the results
-  while ($qry->fetchInto($row)) {
+  while (dbFetchInto($qry, $row)) {
     echo "<tr><td class=\"$class\"><b>$TABLE</b></td>\n";
     // ** TABLE DATA **
Index: /trunk/ippMonitor/raw/getimage.php
===================================================================
--- /trunk/ippMonitor/raw/getimage.php	(revision 39497)
+++ /trunk/ippMonitor/raw/getimage.php	(revision 39498)
@@ -17,5 +17,5 @@
 // load an image file from the image directory
 // validate request
-if ($_SERVER[REQUEST_METHOD] != 'GET') { 
+if ($_SERVER['REQUEST_METHOD'] != 'GET') { 
   exit ();
 }
@@ -37,5 +37,5 @@
 
 // $basename may contain filename@filerule
-$basename = $_GET[name];
+$basename = $_GET['name'];
 if ($basename == "noimage.noimage") {
   $file = fopen ("noimage.png", "r");//$MISSING?
@@ -47,7 +47,7 @@
   exit ();
 }
-$filerule = $_GET[rule];
-$camera   = $_GET[camera];
-$class_id = $_GET[class_id];
+$filerule = $_GET['rule'];
+$camera   = $_GET['camera'];
+$class_id = $_GET['class_id'];
 
 # $filerule = strtok("@");
Index: /trunk/ippMonitor/raw/histogram.php
===================================================================
--- /trunk/ippMonitor/raw/histogram.php	(revision 39497)
+++ /trunk/ippMonitor/raw/histogram.php	(revision 39498)
@@ -101,5 +101,5 @@
   menu_end();
 }
-if (!$qry->fetchInto($row)) {
+if (!dbFetchInto($qry, $row)) {
   echo "<b>error reading camRun, chipRun, rawExp, camProcessedExp table count</b><br>\n";
   echo "<br><small><b> count query : $sql </b></small><br>\n";
@@ -376,5 +376,5 @@
 }
 // ** TAIL CODE **
-while ($qry->fetchInto($row)) {
+while (dbFetchInto($qry, $row)) {
   foreach ($keysToRowIndex as $i => $value) {
     if (get_value_from_key($i, TRUE) == "on") {
Index: /trunk/ippMonitor/raw/ipp.php
===================================================================
--- /trunk/ippMonitor/raw/ipp.php	(revision 39497)
+++ /trunk/ippMonitor/raw/ipp.php	(revision 39498)
@@ -1,4 +1,5 @@
 <?php
 
+$debug = 0;
 $dTABLE = 80;
 include 'site.php';
@@ -50,5 +51,5 @@
   echo "<table class=select>\n";
   echo "<tr class=select><th class=select> projects </th></tr>\n";
-  while ($qry->fetchInto($row)) {
+  while (dbFetchInto($qry, $row)) {
     // add a link here to set the database
     $tmp_proj = $row[0];
@@ -56,8 +57,25 @@
     echo "<tr class=select><td class=select><a class=\"menutop\" href=\"SelectProject.php?$tmp_link&proj=$tmp_proj&new=1\"> $row[0] </a></td></tr>\n";
     // echo "<tr class=select><td class=select> $row[0] </td></tr>\n";
-  }
+  } 
   echo "</table>\n";
 
   menu_end ();
+}
+
+function dbFetchInto ($qry, &$result) {
+  global $DBI;
+
+  if ($DBI == "MDB2") {
+    $result = $qry->fetchRow();
+    if ($result == NULL) {
+      $success = 0;
+    } else {
+      $success = 1;
+    }
+  }
+  if ($DBI == "DB") {
+    $success = $qry->fetchInto($result);
+  }
+  return $success;
 }
 
@@ -87,18 +105,21 @@
 
   // connect to the database
+  if ($database == $CZARDBNAME) {
+    $dsn = "mysql://$DBUSER:$DBPASS@$CZARDBHOST/$database";
+    $dsnerr = "mysql://$DBUSER:XXX@$CZARDBHOST/$database"; // only used to report the error
+  } else {
+    $dsn = "mysql://$DBUSER:$DBPASS@$DBHOST/$database";
+    $dsnerr = "mysql://$DBUSER:XXX@$DBHOST/$database"; // only used to report the error
+  }
   if ($DBI == "DB") {
-    if ($database == $CZARDBNAME) {
-        $db = DB::connect("mysql://$DBUSER:$DBPASS@$CZARDBHOST/$database");
-    } else {
-        $db = DB::connect("mysql://$DBUSER:$DBPASS@$DBHOST/$database");
-    }
+    $db = DB::connect($dsn);
   }
   if ($DBI == "MDB2") {
-    $db = MDB2::connect("mysql://$DBUSER:$DBPASS@$DBHOST/$database");
+    $db = MDB2::connect($dsn);
   }
 
   if (dberror($db)) {
     echo "<b>error accessing database</b><br>\n";
-    echo "<b>tried mysql://$DBUSER:XXX@$DBHOST/$database</b><br>\n";
+    echo "<b>tried $dsnerr</b><br>\n";
     $result = $db->getMessage();
     echo "$result<br>";
@@ -112,5 +133,5 @@
 
   if ($DBI == "MDB2") {
-    $dberr = MDB2::isError($db);
+    $dberr = PEAR::isError($db);
   }
   if ($DBI == "DB") {
@@ -129,6 +150,6 @@
 function checkLogin () {
 
-  $username = $_POST[username];
-  $password = $_POST[password];
+  $username = $_POST['username'];
+  $password = $_POST['password'];
 
   // if password is not specified, keep username and ask again
@@ -143,6 +164,6 @@
   // get the users from the DB
   $sql = "SELECT username FROM users WHERE username = '$username' AND password = '$password'";
-
   $qry = $db->query($sql);
+
   if (dberror($db)) {
     menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
@@ -152,6 +173,6 @@
     menu_end();
   }
-  
-  $success = $qry->fetchInto($row);
+
+  $success = dbFetchInto($qry, $row);
   if (!$success) {  
     menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
@@ -174,5 +195,5 @@
   }
 
-  if ($qry->fetchInto($row)) {
+  if (dbFetchInto($qry, $row)) {
     $ID['pass'] = $row[1];
   } else {
@@ -197,6 +218,4 @@
 
 function checkID () {
-
-
   $VERBOSE = 0;
   if ($VERBOSE > 1) {
@@ -205,5 +224,5 @@
 
   // check for valid server method
-  if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
+  if (($_SERVER['REQUEST_METHOD'] != 'POST') && ($_SERVER['REQUEST_METHOD'] != 'GET')) {
     menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
     echo "Invalid Client Request<br>\n";
@@ -213,9 +232,9 @@
 
   // look for pass & proj in appropriate location
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $ID['pass'] = $_GET[pass];
-    $ID['proj'] = $_GET[proj];
-    $ID['menu'] = $_GET[menu];
-    $ID['from'] = $_GET[from];
+  if ($_SERVER['REQUEST_METHOD'] == 'GET') { 
+    $ID['pass'] = array_key_exists('pass', $_GET) ? $_GET['pass'] : "";
+    $ID['proj'] = array_key_exists('proj', $_GET) ? $_GET['proj'] : "";
+    $ID['menu'] = array_key_exists('menu', $_GET) ? $_GET['menu'] : "";
+    $ID['from'] = array_key_exists('from', $_GET) ? $_GET['from'] : "";
 
     if ($VERBOSE) {
@@ -227,9 +246,9 @@
     }
   }
-  if ($_SERVER[REQUEST_METHOD] == 'POST') { 
-    $ID['pass'] = $_POST[pass];
-    $ID['proj'] = $_POST[proj];
-    $ID['menu'] = $_POST[menu];
-    $ID['from'] = $_POST[from];
+  if ($_SERVER['REQUEST_METHOD'] == 'POST') { 
+    $ID['pass'] = array_key_exists('pass', $_POST) ? $_POST['pass'] : "";
+    $ID['proj'] = array_key_exists('proj', $_POST) ? $_POST['proj'] : "";
+    $ID['menu'] = array_key_exists('menu', $_POST) ? $_POST['menu'] : "";
+    $ID['from'] = array_key_exists('from', $_POST) ? $_POST['from'] : "";
 
     if ($VERBOSE) {
@@ -264,5 +283,5 @@
   }
   
-  $success = $qry->fetchInto($row);
+  $success = dbFetchInto($qry,$row);
   if (! $success) {
     menu('ipp.menu.dat', 'Login', 'ipp.css', '', '');
@@ -359,5 +378,5 @@
     }
 	
-    $thisname = $_SERVER[SCRIPT_NAME]; 
+    $thisname = $_SERVER['SCRIPT_NAME']; 
     $page = "$root/" . $base;
     if ($page == $thisname) {
@@ -396,9 +415,5 @@
   $sortKey = "";
   // try sort forward
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $sortVal = $_GET['sort']; 
-  } else {
-    $sortVal = $_POST['sort'];
-  }
+  $sortVal = get_htmlkey_value ('sort');
   if ($sortVal != "") {
     $sortKey = "&sort=" . $sortVal;
@@ -406,9 +421,5 @@
   // try sort reverse
   if ($sortKey == "") {
-    if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-      $sortVal = $_GET['rsort']; 
-    } else {
-      $sortVal = $_POST['rsort'];
-    }
+    $sortVal = get_htmlkey_value ('rsort');
     if ($sortVal != "") {
       $sortKey = "&rsort=" . $sortVal;
@@ -473,8 +484,8 @@
   }
 
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET[$htmlkey]; 
-  } else {
-    $value = $_POST[$htmlkey];
+  if ($_SERVER['REQUEST_METHOD'] == 'GET') { 
+    $value = array_key_exists($htmlkey, $_GET) ? $_GET[$htmlkey] : ""; 
+  } else {
+    $value = array_key_exists($htmlkey, $_POST) ? $_POST[$htmlkey] : ""; 
   }
   if ($value == "") { return $where; }
@@ -517,18 +528,10 @@
   }
 
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET['sort']; 
-  } else {
-    $value = $_POST['sort'];
-  }
+  $value = get_htmlkey_value ('sort');
   if ($value != "") {
     $where = $where . " ORDER BY $value";
     return $where;
   }
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET['rsort']; 
-  } else {
-    $value = $_POST['rsort'];
-  }
+  $value = get_htmlkey_value ('rsort');
   if ($value != "") {
     $where = $where . " ORDER BY $value DESC";
@@ -538,12 +541,18 @@
 }
 
+function get_htmlkey_value ($htmlkey) {
+  if ($_SERVER['REQUEST_METHOD'] == 'GET') { 
+    $value = array_key_exists($htmlkey, $_GET) ? $_GET[$htmlkey] : ""; 
+  } else {
+    $value = array_key_exists($htmlkey, $_POST) ? $_POST[$htmlkey] : ""; 
+  }
+  return $value;
+}
+
 // if we have a restriction for a string-valued field, supply it to outgoing links
 function button_restrict_string ($key, $line) {
   $htmlkey = preg_replace ('|\.|', '_', $key);
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET[$htmlkey]; 
-  } else {
-    $value = $_POST[$htmlkey];
-  }
+  $value = get_htmlkey_value ($htmlkey);
+
   # a search restriction may include an SQL wild-card.  we have to mangle these so that the http 
   # does not get converted to a special character
@@ -563,9 +572,5 @@
   $htmlkey = preg_replace ('|\.|', '_', $key);
   $htmlkey = $htmlkey . '_min';
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET[$htmlkey]; 
-  } else {
-    $value = $_POST[$htmlkey];
-  }
+  $value = get_htmlkey_value ($htmlkey);
   if ($value != "") {
     if ($line) {
@@ -582,9 +587,5 @@
   $htmlkey = preg_replace ('|\.|', '_', $key);
   $htmlkey = $htmlkey . '_max';
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET[$htmlkey]; 
-  } else {
-    $value = $_POST[$htmlkey];
-  }
+  $value = get_htmlkey_value ($htmlkey);
   if ($value != "") {
     if ($line) {
@@ -600,9 +601,5 @@
 function button_restrict_checkbox ($key, $line) {
   $htmlkey = preg_replace ('|\.|', '_', $key);
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET[$htmlkey]; 
-  } else {
-    $value = $_POST[$htmlkey];
-  }
+  $value = get_htmlkey_value ($htmlkey);
   if ($value != "") {
     if ($line) {
@@ -618,9 +615,5 @@
 function button_restrict_radio ($key, $line) {
   $htmlkey = preg_replace ('|\.|', '_', $key);
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET[$htmlkey]; 
-  } else {
-    $value = $_POST[$htmlkey];
-  }
+  $value = get_htmlkey_value ($htmlkey);
   if ($value != "") {
     if ($line) {
@@ -648,12 +641,12 @@
   }
 
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $up   = $_GET['rsort']; 
-    $down = $_GET['sort']; 
-    $from = $_GET['from']; 
-  } else {
-    $up   = $_POST['rsort']; 
-    $down = $_POST['sort']; 
-    $from = $_POST['from']; 
+  if ($_SERVER['REQUEST_METHOD'] == 'GET') { 
+    $up   = array_key_exists('rsort', $_GET) ? $_GET['rsort'] : "";
+    $down = array_key_exists('sort',  $_GET) ? $_GET['sort'] : "";
+    $from = array_key_exists('from',  $_GET) ? $_GET['from'] : "";
+  } else {
+    $up   = array_key_exists('rsort', $_POST) ? $_POST['rsort'] : "";
+    $down = array_key_exists('sort',  $_POST) ? $_POST['sort'] : "";
+    $from = array_key_exists('from',  $_POST) ? $_POST['from'] : "";
   }
 
@@ -695,9 +688,5 @@
     $htmlkey = $htmlkey . "_max";
   }
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET[$htmlkey]; 
-  } else {
-    $value = $_POST[$htmlkey];
-  }
+  $value = get_htmlkey_value ($htmlkey);
 
   // full table element includes optionally the <= or >= words
@@ -714,10 +703,6 @@
 function write_query_checkbox ($key, $comment) {
   $htmlkey = preg_replace ('|\.|', '_', $key);
-
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET[$htmlkey]; 
-  } else {
-    $value = $_POST[$htmlkey];
-  }
+  $value = get_htmlkey_value ($htmlkey);
+
   echo "<td> <input type=\"checkbox\" name=\"$htmlkey\"";
   if ($value == "on") { 
@@ -734,9 +719,5 @@
   $htmlvalue = preg_replace ('|\.|', '_', $value);
 
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $value = $_GET[$htmlkey]; 
-  } else {
-    $value = $_POST[$htmlkey];
-  }
+  $value = get_htmlkey_value ($htmlkey);
   if ($htmlvalue == get_value_from_key($htmlkey, TRUE)) {
     $checked = "checked";
@@ -779,12 +760,12 @@
 function insert_image ($rule, $size) {
 
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $basename = $_GET['basename']; 
-    $class_id = $_GET['class']; 
-    $camera   = $_GET['camera']; 
-  } else {
-    $basename = $_POST['basename']; 
-    $class_id = $_POST['class']; 
-    $camera   = $_POST['camera']; 
+  if ($_SERVER['REQUEST_METHOD'] == 'GET') { 
+    $basename = array_key_exists('basename', $_GET) ? $_GET['basename'] : "";
+    $class_id = array_key_exists('class',    $_GET) ? $_GET['class']    : "";
+    $camera   = array_key_exists('camera',   $_GET) ? $_GET['camera']   : "";
+  } else {
+    $basename = array_key_exists('basename', $_POST) ? $_POST['basename'] : "";
+    $class_id = array_key_exists('class',    $_POST) ? $_POST['class']    : "";
+    $camera   = array_key_exists('camera',   $_POST) ? $_POST['camera']   : "";
   }
 
@@ -802,14 +783,14 @@
 function insert_log ($filerule) {
 
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $basename = $_GET['basename']; 
-    $class_id = $_GET['class']; 
-    $camera   = $_GET['camera']; 
-    $state    = $_GET['state']; 
-  } else {
-    $basename = $_POST['basename']; 
-    $class_id = $_POST['class']; 
-    $camera   = $_POST['camera']; 
-    $state    = $_POST['state']; 
+  if ($_SERVER['REQUEST_METHOD'] == 'GET') { 
+    $basename = array_key_exists('basename', $_GET) ? $_GET['basename'] : "";
+    $class_id = array_key_exists('class',    $_GET) ? $_GET['class']    : "";
+    $camera   = array_key_exists('camera',   $_GET) ? $_GET['camera']   : "";
+    $state    = array_key_exists('state',    $_GET) ? $_GET['state']    : "";
+  } else {
+    $basename = array_key_exists('basename', $_POST) ? $_POST['basename'] : "";
+    $class_id = array_key_exists('class',    $_POST) ? $_POST['class']    : "";
+    $camera   = array_key_exists('camera',   $_POST) ? $_POST['camera']   : "";
+    $state    = array_key_exists('state',    $_POST) ? $_POST['state']    : "";
   }
 
@@ -830,5 +811,7 @@
   //It's necessary for staticsky logs and it would require to join tables
   //back to the warpRun table
-  if (! $camera) { $camera = strtoupper($_GET['proj']); }
+  if (! $camera) { 
+    $camera = strtoupper($_GET['proj']); 
+  }
 
   if ($basename && $camera && $filerule) {
@@ -886,9 +869,5 @@
 function insert_backref ($page, $key, $link) {
 
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    $name = $_GET[$key]; 
-  } else {
-    $name = $_POST[$key]; 
-  }
+  $name = get_htmlkey_value ($key);
 
   if ($name) {
@@ -911,9 +890,6 @@
     $htmlkey = $key;
   }
-  if ($_SERVER[REQUEST_METHOD] == 'GET') { 
-    return $_GET[$htmlkey]; 
-  } else {
-    return $_POST[$htmlkey]; 
-  }
+  $value = get_htmlkey_value ($key);
+  return $value;
 }
 
Index: /trunk/ippMonitor/raw/masterDetrendImfiles.php
===================================================================
--- /trunk/ippMonitor/raw/masterDetrendImfiles.php	(revision 39497)
+++ /trunk/ippMonitor/raw/masterDetrendImfiles.php	(revision 39498)
@@ -53,5 +53,5 @@
 
 // list the results
-while ($qry->fetchInto($row)) {
+while (dbFetchInto($qry, $row)) {
   // $link = "masterDetrendImfiles.php" . "?expID=" . $row[0] . "&" . $ID['link'];
 
Index: /trunk/ippMonitor/raw/nightSummary.php
===================================================================
--- /trunk/ippMonitor/raw/nightSummary.php	(revision 39497)
+++ /trunk/ippMonitor/raw/nightSummary.php	(revision 39498)
@@ -25,5 +25,5 @@
 
   // list the results
-  while ($qry->fetchInto($row)) {
+  while (dbFetchInto($qry, $row)) {
     echo "<tr><td class=\"$class\"><b>$TABLE</b></td>\n";
     // ** TABLE DATA **
Index: /trunk/ippMonitor/raw/simplePlot.php
===================================================================
--- /trunk/ippMonitor/raw/simplePlot.php	(revision 39497)
+++ /trunk/ippMonitor/raw/simplePlot.php	(revision 39498)
@@ -81,5 +81,5 @@
   menu_end();
 }
-if (!$qry->fetchInto($row)) {
+if (!dbFetchInto($qry, $row)) {
   echo "<b>error reading chipRun, rawExp table count</b><br>\n";
   echo "<br><small><b> count query : $sql </b></small><br>\n";
@@ -238,5 +238,5 @@
 
 // list the results
-while ($qry->fetchInto($row)) {
+while (dbFetchInto($qry, $row)) {
   switch ($row[2]) {
    case 'g.00000':
Index: /trunk/ippMonitor/raw/simplePlotcam.php
===================================================================
--- /trunk/ippMonitor/raw/simplePlotcam.php	(revision 39497)
+++ /trunk/ippMonitor/raw/simplePlotcam.php	(revision 39498)
@@ -84,5 +84,5 @@
   menu_end();
 }
-if (!$qry->fetchInto($row)) {
+if (!dbFetchInto($qry, $row)) {
   echo "<b>error reading camProcessedExp, camRun, chipRun, rawExp table count</b><br>\n";
   echo "<br><small><b> count query : $sql </b></small><br>\n";
@@ -246,5 +246,5 @@
 
 // list the results
-while ($qry->fetchInto($row)) {
+while (dbFetchInto($qry, $row)) {
   switch ($row[2]) {
    case 'g.00000':
Index: /trunk/ippMonitor/raw/simplePlotraw.php
===================================================================
--- /trunk/ippMonitor/raw/simplePlotraw.php	(revision 39497)
+++ /trunk/ippMonitor/raw/simplePlotraw.php	(revision 39498)
@@ -75,5 +75,5 @@
   menu_end();
 }
-if (!$qry->fetchInto($row)) {
+if (!dbFetchInto($qry, $row)) {
   echo "<b>error reading rawExp table count</b><br>\n";
   echo "<br><small><b> count query : $sql </b></small><br>\n";
@@ -218,5 +218,5 @@
 
 // list the results
-while ($qry->fetchInto($row)) {
+while (dbFetchInto($qry, $row)) {
   switch ($row[2]) {
    case 'g.00000':
Index: /trunk/ippMonitor/raw/warpProcessedExp.php
===================================================================
--- /trunk/ippMonitor/raw/warpProcessedExp.php	(revision 39497)
+++ /trunk/ippMonitor/raw/warpProcessedExp.php	(revision 39498)
@@ -99,5 +99,5 @@
   menu_end();
 }
-if (!$qry->fetchInto($row)) {
+if (!dbFetchInto($qry, $row)) {
   echo "<b>error reading warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary table count</b><br>\n";
   echo "<br><small><b> count query : $sql </b></small><br>\n";
@@ -295,5 +295,5 @@
 
 // list the results
-while ($qry->fetchInto($row)) {
+while (dbFetchInto($qry, $row)) {
   // $link = "warpProcessedExp.php" . "?expID=" . $row[0] . "&" . $ID['link'];
 
Index: /trunk/ippMonitor/raw/warpProcessedExp_Images.php
===================================================================
--- /trunk/ippMonitor/raw/warpProcessedExp_Images.php	(revision 39497)
+++ /trunk/ippMonitor/raw/warpProcessedExp_Images.php	(revision 39498)
@@ -91,5 +91,5 @@
   menu_end();
 }
-if (!$qry->fetchInto($row)) {
+if (!dbFetchInto($qry, $row)) {
   echo "<b>error reading warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary table count</b><br>\n";
   echo "<br><small><b> count query : $sql </b></small><br>\n";
@@ -307,5 +307,5 @@
 
 // list the results
-while ($qry->fetchInto($row)) {
+while (dbFetchInto($qry, $row)) {
   // $link = "warpProcessedExp_Images.php" . "?expID=" . $row[0] . "&" . $ID['link'];
 
