MyBB Community Forums

Full Version: Including config.php
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've made a mod that requires the use of the database connection variables in config.php

This mod is for the admin panel, and is stored in the admin folder. How would I include the config.php file so that its variables can be used in mine?

I've tried everything I can think of, but nothing seems to work!
you need to add
require "global.php";
at the top of your file. and if you define a function, you need to add
global $db;
in that function, so that you have something like
function some_name(){
global $db;
$query = $db->query("...............");
..........
}
As Smethead said, you should include the global.php file. This will get all the variables you need, it will also connect to databases and setup templates. It will also do other stuff like manage users.

If you just want the variables (and database class), you can include the init.php file
require_once("inc/init.php")
That won't do things like manage users.

Either way, if you are using the information inside a plugin function, you will need to declare
global $config;
to get the database variables (host, user_name etc)