db = @mysql_pconnect($DBServer, $DBUser, $DBPassword); $this->DBName = $DBName; if (!$this->db) { print('We\'re sorry, but the database is not responding. Please check back in a bit, we are working on the problem!'); mail('admin@yoursite.com', 'Database not responding', 'Unable to connect to the database: '.$DBServer.':'.$DBName); exit; } } function GetValue($SQLStmt, $Field = 'val', $debug = false) { if ($debug) { Debug('SQL.GetValue: '.$SQLStmt.'; value: '.$Field); } $r = mysql_db_query($this->DBName, $SQLStmt, $this->db) or die ('

no results on SQL.GetValue '.$SQLStmt.'; '.$Field); $t = mysql_fetch_array($r); return stripslashes($t[$Field]); } function GetRow($SQLStmt, $debug = false) { if ($debug) { Debug('SQL.GetRow: '.$SQLStmt); } $r = mysql_db_query($this->DBName, $SQLStmt, $this->db) or die ('

no results on SQL.GetRow '.$SQLStmt); $t = mysql_fetch_array($r); if ($t) { array_walk($t, 'strip'); } return $t; } function GetSet($SQLStmt, $debug = false, $noexec = false) { if ($debug) { Debug('SQL.GetSet: '.$SQLStmt); } if (!$noexec) { $r = mysql_db_query($this->DBName, $SQLStmt, $this->db) or die ('

no results on SQL.GetSet '.$SQLStmt); $i = 0; if (mysql_num_fields($r) > 1) { while ($t = mysql_fetch_array($r)) { $val[$i] = $t; array_walk($val[$i], 'strip'); $i++; } } else { while ($t = mysql_fetch_row($r)) { $val[$i] = stripslashes($t[0]); $i++; } } return $val; } } function Exists($SQLStmt = '', $debug = false) { if ($debug) { Debug('SQL.Exists: '.$SQLStmt); } $val = $this->GetValue($SQLStmt); if ($val) { return true; } else { return false; } } function Execute($SQLStmt, $debug = false) { if ($debug) { Debug('SQL.Execute: '.$SQLStmt); } mysql_db_query($this->DBName, $SQLStmt, $this->db) or die ('

no results on SQL.Execute '.$SQLStmt); } } function Debug($message, $stop = false) { print("\n\n\n".'
Debug:'); if (is_null($message)) { print('null'); } else if ($message === true) { print('Boolean true'); } else if ($message === false) { print('Boolean false'); } print_r($message); wprint('
'."\n"); if ($stop) { exit; } } ?>