The DB connection is made in the following file:
So this means you have to include this file at the top of each page that is going to use the $db class for queries.
include($phpbb_root_path . 'common.' . $phpEx);
Else if you don't want to use that you could make your own connection.
By doing this:
Then save this in a seperate file so you can just include it when you need the connection to do queries.
// this file stores the database variables
include($phpbb_root_path . 'config.' . $phpEx);
// the engine you want to use.
// you wanted to use mysql so its best to select the mysqli class
include($phpbb_root_path . 'includes/db/mysqli.' . $phpEx);
// new instance of db
$db = new $sql_db();
// connect to database
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false);
// unset for safety purposes
Also I noticed your calling your custom $site->page_footer();
Note sins your not using the phpbb footer.
You'll have to close the database connection in your custom footer script.
in this->page_footer function
This is all possible. But my first example with the correct structure is the best way to go. Sins it gives you all phpbb functions, sessions, cache options and tons more. And believe me when I say this its alot easier to use the functions already there then reinventing everything.
global $cache, $db;
// Unload cache, must be done before the DB connection if closed
// Close our DB connection.