database.php 1.4 KB
Newer Older
mattl's avatar
mattl committed
1 2
<?php

3
/* GNU FM -- a free network service for sharing your music listening habits
mattl's avatar
mattl committed
4

5
   Copyright (C) 2009, 2015 Free Software Foundation, Inc
mattl's avatar
mattl committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

   This program is free software: you can redistribute it and/or modify
   it under the terms of the GNU Affero General Public License as published by
   the Free Software Foundation, either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU Affero General Public License for more details.

   You should have received a copy of the GNU Affero General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

jurgbohn's avatar
jurgbohn committed
22

23
if (!file_exists(dirname(__FILE__) . '/config.php')) {
24
	die('Please run the <a href="install.php">Install</a> script to configure your installation');
elleo's avatar
elleo committed
25 26 27
}

require_once('config.php');
28 29 30

try {
	$adodb =& NewADOConnection($connect_string);
31
} catch (Exception $e) {
32
	die("Unable to connect to database.");
elleo's avatar
elleo committed
33 34
}

35 36 37 38 39 40 41 42 43 44 45 46 47 48
/**
 * Write error to Error database table
 *
 * @param string msg Message
 * @param string data Data
 * @return null
 */
function reportError($msg, $data) {
	global $adodb;

	$adodb->Execute('INSERT INTO Error(msg, data, time) VALUES('
		. $adodb->qstr($msg) . ', '
		. $adodb->qstr($data) . ', '
		. time() . ')');
49
}