Topic: $db_forum & including essentials.php
While integrating PunBB for single sign-on with my website, I had a problem whenever I'd call a function from functions.php (through essentials.php which was included in my script.) Specifically I was calling add_user(), and $db_forum was never defined, even if it is declared global at the begenning of the function.
After much frustration, I have found that it is a problem in PHP, (I'm running 5.0.4, dunno if it's fixed now, I'll check their tracker later) according to larax at o2 dot pl on http://ca2.php.net/global . A workaround is to add global $db_forum before $db_forum is set. So in /include/dblayer/common.php , you would get:
global $forum_db;
$forum_db = new DBLayer($db_host, $db_username, $db_password, $db_name, $db_prefix, $p_connect);
at the end of the file.
This most likely happens with other globals used in functions.php.