1
我遇到了更改我的配置文件config.php
的問題。目前,我試圖通過駐留在同一目錄中的表單配置數據庫細節$config['db]
,但是,當我包含配置文件時,channges不會實現。這裏是config.php的樣子:使可配置的config.php文件
<?php
//main path to resources
$resources = dirname(__DIR__);
//$root = dirname(dirname(__DIR__));
$root = dirname($resources);
//configuration array to hold
//vital information
$config = array(
"db" => array(
"username" => null,
"password" => null,
"host" => null,
"database" => null
),
"directories" => array(
"document_root" => $root,
"site_root" => $root . '/public_html',
"resources" => $resources,
"templates" => $resources . '/templates',
"library" => $resources . '/library',
"views" => $resources . '/views',
"controllers" => $resources . '/controllers',
"backups" => $resources . '/backups',
"admin" => $resources . '/admin'
),
"pages" => array(
"index" => array(
"title" => "Welcome, you can order your tickets to St. Tom's
Ambulance annual ball here",
"headers" => array("introduction", "the process", "start"),
"views" => array("/index.form.view.php", "/index.data.view.php",
"/index.side.view.php")
),
"login" => array(
"title" => "Log in here so as to place your order.",
"headers" => array("log in", "guests' details", "choose seats"),
"views" => array("/login.view.php", "/guests.view.php",
"/table.select.order.view.php")
),
"amend" => array(
"title" => "Amend your order here.",
"headers" => array("enter order no.", "available seats",
"amend seats"),
"views" => array("/amend.view.form.php",
"/table.select.amend.view.php", "/amend.view.side.php")
),
"menus" => array(
"title" => "Select your menus and checkout here.",
"headers" => array("view menus", "select menus",
"check out"),
"views" => array("/menus.see.view.php",
"/menus.select.view.php", "/checkout.view.php")
),
"message" => array(
"title" => "Information about your order."
),
"amend_message" => array(
"title" => "Information about your ammendment."
)
),
"month" => array("January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"),
"ticket_price" => 30,
"year_limit" => (2010 - 13),
"event_dateTime" => '2010-11-20 19:00:00'
);
require_once($config['directories']['library']. "/class/FormDB.php");
$form = new FormDB($config["db"]["host"],
$config["db"]["username"],
$config["db"]["password"],
$config["db"]["database"],
$config["event_dateTime"]);
?>
那麼你真的在哪裏改變配置文件的內容? – NullUserException 2010-07-27 13:57:25
這段代碼沒有顯示。然而,通過檢查$ _SESSION ['db']是否存在,我從表單輸入中創建一個$ _SESSION ['db'],然後將它傳遞給config.php文件中的$ config ['db']。問題是,當我訪問長網址http:// localhost/...的網站時,這起作用,但是當我嘗試從虛擬主機http://st.ambulance/...訪問網站時它不再工作了。 – Fortisimo 2010-07-27 14:17:44