Topic: Trouble with parse_message

Are calling parse_message() from one of my own functions but get the error:
Fatal error: Call to a member function on a non-object in /home/www-data/saunalan/forum/include/common.php on line 427

A check shows that that is the censor_words-function that is trying to use the db-object.

I suspect it got something to do with my many includes, and perhaps the db-layer-scope-or-what-its-called.
I do the following:

In my own index.php

<?
chdir('forum');
require('config.php');
require('include/common.php');
require('include/parser.php');
chdir('..');

require('inc/functions.php');

$some_text = "mekkish";

ob_start();
    db_include($some_text);
    $main_content = ob_get_contents();
ob_end_clean();

echo $main_content;
?>

In inc/functions.php

<?
function db_include($text) {
    echo parse_message($text,1);
}
?>

*The code is stripped of non-relevant stuff

Re: Trouble with parse_message

Well, it almost sounds as if you're unsetting (or resetting) $db to something else in one of you includes (probably functions.php).

Try dumping the contents of $db in different places in the code to determine where it's affected. You can use the function dump() that is defined in common.php.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3 (edited by Shadowie 2003-10-04 23:42)

Re: Trouble with parse_message

User error caused it smile
I had forgotten that I use $db in my own db-include.

And
global $db;
is needed in the censor-function too.