summaryrefslogtreecommitdiffstats
path: root/libglue/dbh.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-06-09 16:34:40 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2005-06-09 16:34:40 +0000
commitbcad40a05ab2dc2a341a3227e30b96668bce4500 (patch)
tree6fca27588d53a1b24705bd2834e9e643bb729bd1 /libglue/dbh.php
downloadampache-bcad40a05ab2dc2a341a3227e30b96668bce4500.tar.gz
ampache-bcad40a05ab2dc2a341a3227e30b96668bce4500.tar.bz2
ampache-bcad40a05ab2dc2a341a3227e30b96668bce4500.zip
New Import
Diffstat (limited to 'libglue/dbh.php')
-rw-r--r--libglue/dbh.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/libglue/dbh.php b/libglue/dbh.php
new file mode 100644
index 00000000..71d04b9c
--- /dev/null
+++ b/libglue/dbh.php
@@ -0,0 +1,53 @@
+<?
+/*
+ * ---------------------------- CVS INFO --------------------------------
+ *
+ * $Source: /data/cvsroot/ampache/libglue/dbh.php,v $
+ * last modified by $Author: vollmerk $ at $Date: 2003/11/24 05:53:13 $
+ *
+ * Libglue, a free php library for handling authentication
+ * and session management.
+ *
+ * Written and distributed by Oregon State University.
+ * http://oss.oregonstate.edu/libglue
+ *
+ * -----------------------------------------------------------------------
+ */
+
+/*----------------------------------------------------------------------
+
+ For complete information on this toolkit see the README located in this
+ directory.
+
+ This is the database handler class. This will setup and return a
+ database handle for use in your application. Simply pass it a
+ username and password. If an error occurs you'll be presented with
+ a verbose reason for the error.
+----------------------------------------------------------------------*/
+
+function setup_sess_db($name, $host, $db, $username, $password)
+{
+ $dbh = @mysql_connect($host, $username, $password) or header("Location:" . conf('web_path') . "/test.php");
+ if ( !is_resource($dbh) )
+ {
+ echo "Unable to connect to \"". $host ."\" in order to \n" .
+ "use the \"". $db ."\" database with account \"".$username." : ".$password.
+ "\"\n . Perhaps the database is not " .
+ "running, \nor perhaps the admin needs to change a few variables in\n ".
+ "the config files in order to point to the correct database.\n";
+ echo "Details: " .
+ mysql_errno() . ": " .
+ mysql_error() . "\n";
+ die();
+ }
+
+ else
+ {
+ @mysql_select_db($db, $dbh) or header("Location:" . conf('web_path') . "/test.php");
+ libglue_param(array($name=>$dbh));
+ }
+
+ return $dbh;
+}
+
+?>