0

Hi friends,
In my site, simply I want to save the configuration data, site details in the php file.
For an example, in vBulletin they are using config.php file to save all the general details.

    //  ****** DATABASE TYPE ******
    //  This is the type of the database server on which your vBulletin database will be located.
    //  Valid options are mysql and mysqli, for slave support add _slave.  Try to use mysqli if you are using PHP 5 and MySQL 4.1+
    // for slave options just append _slave to your preferred database type.
$config['Database']['dbtype'] = 'mysql';

    //  ****** DATABASE NAME ******
    //  This is the name of the database where your vBulletin will be located.
    //  This must be created by your webhost.
$config['Database']['dbname'] = 'test';

    //  ****** TABLE PREFIX ******
    //  Prefix that your vBulletin tables have in the database.
$config['Database']['tableprefix'] = '';

I want to store details such as Site Name, database connection and some other things.
How can I do it?

2
Contributors
5
Replies
27
Views
3 Years
Discussion Span
Last Post by jKidz
0

Config files come in all shapes and sizes. You can have plain php files where you store data in constants or variables. Alternatively, you can store config data in an ini file. These are special format text files which can be read using parse_ini_file()

The scope and form pretty much depends upon the complexity of your site. You may find a simple include file with a few vars or constants sufficient for your needs. The config file needs to be simple enough typically with just assignments, so it can be used with ajax calls. When you start creating too many dependencies, simple ajax calls can become a nightmare. Also watch out for duplication - that's a killer.

If you're storing sensitive data like db passwords in your config file, remember to store it above the document root, so it can't be accessed outside your own scripts.

Edited by diafol

0

Thank you very much for your reply.
Can you explain more above this section please? How can I store that file above the document root.

If you're storing sensitive data like db passwords in your config file, remember to store it above the document root, so it can't be accessed outside your own scripts.

1

Your document root is that folder which is accessible to the world (public), it is sometimes called "public_html" or "htdocs" or possibly other things (the "directory" where you usually place your index.html or index.php page), anyway, create a folder above this, and place your config file there if it contains sensitive data like passwords.

Edited by diafol

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.