blob: 71d04b9c11587f49264105cd59bcdbe6e83a480e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
}
?>
|