MyBB Community Forums

Full Version: MyBB Datachache
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,

I'm creating a multi-forum MyBB host, and I'm having some trouble with the datachache when creating a new forum.

I'm currently using this query...
$cache = "a:7:{s:10:\"numthreads\";i:0;s:20:\"numunapprovedthreads\";i:0;s:8:\"numposts\";i:0;s:18:\"numunapprovedposts\";i:0;s:8:\"numusers\";s:1:\"1\";s:7:\"lastuid\";s:1:\"1\";s:12:\"lastusername\";s:6:\"$uname\";}";
mysql_query("UPDATE ".$table."datacache SET cache='".$cache."' WHERE title='stats'");

But when I create a new forum, the newest user shows up as "no-one".

How can I fix this?

Thanks.
Don't update the datacache table, just create the forum and call $cache->update_forums(); Trying to update the cache with a query like that will only make things much harder for you.
Ok, I tried that, and it gives me the following error:

Fatal error: Call to a member function update_forums() on a non-object
Have you globalised $cache in your function?? Has global.php been included??
Yes, global.php has been included.
Actually $cache is initialised in ./inc/init.php so I can't see why $cache->update_forums() doesn't work. What does this output??

var_dump(is_object($cache));

Should be bool(true)
It outputs bool(false)
Undecided

The only thing I can think of is that you're calling this inside a function and you haven't globalised $cache like I mentioned above. For anything MyBB-wise to work you'd have init.php included via global.php and $cache is defined there.
global $cache, $db, $mybb

Make sure that's inside your function.
Ok, I'm using this...

require_once 'inc/class_datacache.php';
$cache = new datacache;
$cache->update_forums();

Which I got from the installation file, but it's throwing an error at me:

Fatal error: Call to a member function simple_select() on a non-object **removed**/inc/class_datacache.php on line 545
Pages: 1 2