Topic: AJAX Chat integration errors

I've installed PunBB, and it's working great. Then I wanted to add AJAX Chat 0.8.3 punbb-version... and that doesn't work.
On index.php in the chat-folder I get "This page contains the following errors:
error on line 2 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error."

Looking at the coding on the page I get this:

<br />
<b>Fatal error</b>:  Call to a member function escape() on a non-object in <b>/home/stedri/public_html/punbb/chat/lib/class/CustomAJAXChat.php</b> on line <b>113</b><br />

The line it refers to is part of this function:

function &getChannels() {
        if($this->_channels === null) {
            global $db,$pun_user;
            
            $this->_channels = array();
            
            // Get valid PunBB forums:
            $sql = 'SELECT
                        id,
                        forum_name
                    FROM
                        '.$db->prefix.'forums AS f
                    LEFT JOIN
                        '.$db->prefix.'forum_perms AS fp
                    ON
                        (fp.forum_id=f.id AND fp.group_id=\''.$db->escape($pun_user['g_id']).'\')  //<----This is line 113
                    WHERE
                        (fp.read_forum IS NULL OR fp.read_forum=1);';
            $result = $db->query($sql);

            $defaultChannelFound = false;

            while ($row = $db->fetch_assoc($result)) {
                // Check if we have to limit the available channels:
                if($this->getConfig('limitChannelList') && !in_array($row['id'], $this->getConfig('limitChannelList'))) {
                    continue;
                }

                $forumName = $this->trimChannelName($row['forum_name']);
                
                $this->_channels[$forumName] = $row['id'];

                if(!$defaultChannelFound && $row['id'] == $this->getConfig('defaultChannelID')) {
                    $defaultChannelFound = true;
                }
            }
            $db->free_result($result);

            if(!$defaultChannelFound) {
                // Add the default channel as first array element to the channel list:
                $this->_channels = array_merge(
                    array(
                        $this->trimChannelName($this->getConfig('defaultChannelName'))=>$this->getConfig('defaultChannelID')
                    ),
                    $this->_channels
                );
            }
        }
        return $this->_channels;
    }

Please help me figure this out. If you need more info, please let me know.

Re: AJAX Chat integration errors

global $db its wrong.
In punbb 1.3 used $forum_db variable.

Re: AJAX Chat integration errors

Thank you for your help. It put me on the track to the next step.

I had to update FABridge.js as well.
When I had gone past that error, I went on to the next. This time, no user in the chat and I couldn't post anything in the chat.

Looking at the reply about the change of variables, I went in search for anything $pun and changed that to $forum... and after that I could see the admin-user in the chat (me).

I still have a problem...
I can't chat. Nothing I write gets put in the chat. I can't see if I'm changing channels either, even though they are nicely listed after my forum-setup.

Where am I going wrong? Please help!