开发者

make configurable config.php file

I'm having problems with changing my configuration file config.php. At the moment, I'm trying to configure the databse details $config['db] through a form residing in the same directory, however, when I include the configuration file the channges do not materialise. Here's what config.php looks like:

<?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开发者_Go百科" => $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"]);
?>


There's no code to change the config.php file itself, and that's probably where the problem lies. Often the issue is the permissions of the configuration file - if it is to be server-configurable (with forms or otherwise), the permissions on the file must allow it.

You can also try a tiny library I wrote way back to manage the configuration of scripts in a more structured way - SQLconf.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜