<?php

function db_connect ()
{
    require $_SERVER["DOCUMENT_ROOT"]."/Config/_dbconfig_.php";
    @$y = mysql_connect($MYSQL_HOST,$MYSQL_USER,$MYSQL_PASS);
    @$x = mysql_select_db($MYSQL_DATABASE);
    if (empty($x))  
    {
        echo "ERROR 0x01, Failed to connect to database!<br>";
        mysql_close();
        return $x;
    }
    else
    {
//        echo $x.",".$y;
        return array($x,$y);
    }
}

function db_getconfval ($attribute)
{
    list($db,$conn) = db_connect();
    if (empty($db))  
    {
        echo "ERROR 0x01, Failed to connect to database!<br>";
        return NULL;
    }
    else
    {
        $sql = "SELECT value FROM config WHERE attr='". mysql_real_escape_string($attribute)."'";
        $result = mysql_query($sql,$conn);
        $data = mysql_fetch_array ($result);
  //      echo $result;
        mysql_close();
        return $data[0];
    }
}

?>
