/* * These functions build the foundation for accessing the database: * it is a general database abstraction layer suitable for several * databases. Currently, the only supported database is MySQL but * it should be straightforward to port it to any other database: * just adjust the handlers to your needs. */ function db_connect() { global $dbhost, $dbuname, $dbpass, $dbname; mysql_pconnect($dbhost, $dbuname, $dbpass) or die(mysql_Error()); mysql_select_db($dbname) or die ("Unable to select database"); // NOTE: we are using a persistent connection! } function db_insert($query, $debug = false) { // NOTE: // add spam- and/or flood-checks db_query($query, $debug); } function db_query($query, $debug = false) { ### perform query: $qid = mysql_query($query); ### debug output (if required): if ($debug || empty($qid)) print "
query: ". htmlspecialchars($query) .""; if (empty($qid)) watchdog(3, "error: ". mysql_error() ."
error message: ". mysql_error() ."