示例#1
0
function initDB()
{
    /* Get Sectors from session */
    if (!isset($_SESSION['databaseURL'])) {
        include "conf/conf.php";
        $dbConf = new AAConf();
        $databaseURL = $dbConf->get_databaseURL();
        $databaseUName = $dbConf->get_databaseUName();
        $databasePWord = $dbConf->get_databasePWord();
        $databaseName = $dbConf->get_databaseName();
        //Set DB Info. in-session
        $_SESSION['databaseURL'] = $databaseURL;
        $_SESSION['databaseUName'] = $databaseUName;
        $_SESSION['databasePWord'] = $databasePWord;
        $_SESSION['databaseName'] = $databaseName;
        $connection = mysql_connect($databaseURL, $databaseUName, $databasePWord);
        // or die ("Error while connecting to localhost");
        $db = mysql_select_db($databaseName, $connection);
        //or die ("Error while connecting to database");
        $rowArray;
        $rowID = 1;
        $query = "SELECT * FROM Sectors";
        $result = mysql_query($query);
        while ($row = mysql_fetch_array($result)) {
            $rowArray[$rowID] = $row['Sector'];
            $rowID = $rowID + 1;
        }
        //Update the session with the sectors.
        $_SESSION['sectors'] = $rowArray;
        mysql_close($connection);
    }
    $databaseURL = $_SESSION['databaseURL'];
    $databaseUName = $_SESSION['databaseUName'];
    $databasePWord = $_SESSION['databasePWord'];
    $databaseName = $_SESSION['databaseName'];
    $connection = mysql_connect($databaseURL, $databaseUName, $databasePWord);
    //or die ("Error while connecting to host");
    $db = mysql_select_db($databaseName, $connection);
    //or die ("Error while connecting to database");
    return $connection;
}
示例#2
0
文件: index.php 项目: robin-001/AIRES
<?php

session_start();
include "conf/conf.php";
$dbConf = new AAConf();
$databaseURL = $dbConf->get_databaseURL();
$databaseUName = $dbConf->get_databaseUName();
$databasePWord = $dbConf->get_databasePWord();
$databaseName = $dbConf->get_databaseName();
//Set DB Info. in-session
$_SESSION['databaseURL'] = $databaseURL;
$_SESSION['databaseUName'] = $databaseUName;
$_SESSION['databasePWord'] = $databasePWord;
$_SESSION['databaseName'] = $databaseName;
$connection = mysql_connect($databaseURL, $databaseUName, $databasePWord);
// or die ("Error while connecting to localhost");
$db = mysql_select_db($databaseName, $connection);
//or die ("Error while connecting to database");
$rowArray;
$rowID = 1;
$query = "SELECT * FROM Sectors";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
    $rowArray[$rowID] = $row['Sector'];
    $rowID = $rowID + 1;
}
//Update the session with the sectors.
$_SESSION['sectors'] = $rowArray;
mysql_close($connection);
?>