PDA

View Full Version : using variables outside vB


Menno
Tue 25th Apr '00, 7:25pm
It it possible to, for say, use the total ammount of posts variable on your mainpage (if that's in php)?

John
Tue 25th Apr '00, 8:36pm
Yup

This is probably code hacking, but you will want something like this:


<?php

//load config
require("config.php");

// init db **********************
// load db class
$dbclassname="db_$dbservertype.php";
require($dbclassname);

$DB_site=new DB_Sql;

$DB_site->appname="vBulletin Front Page Hack";
$DB_site->appshortname="vBulletin (front)";
$DB_site->database=$dbname;
$DB_site->server=$servername;
$DB_site->user=$dbusername;
$DB_site->password=$dbpassword;

$DB_site->connect();
// end init db

$posts=$DB_site->query_first("SELECT MAX(postid) AS posts FROM post");
echo $posts[posts];

?>


There ya go - untested, but it should work.

John

Menno
Tue 25th Apr '00, 9:07pm
crud, it didn't work for me
Thanks for trying though :)
could anybody gimme a hand?

[Edited by Menno on 04-26-2000 at 09:25 AM]

John
Tue 25th Apr '00, 10:26pm
Sorry - I meant to say something about the includes. You will need to include the full path to the admin directory of vBulletin in the code that I gave you:


require("/www/htdocs/forum/admin/config.php");


and


$dbclassname="/www/htdocs/forum/admin/db_$dbservertype.php";


Obviously you will want to change the paths to your own values.

John

Menno
Tue 25th Apr '00, 11:15pm
actually, I put the file (to use the variable) inm the forums/admin dir

is db_$dbservertype.php located there (and what exactly is db_$dbservertype.php)?

Thanks for your help :)

Mike Sullivan
Wed 26th Apr '00, 3:57am
It contains a bunch of different MySQL functions in a class (?). $DB_site uses it universally.

Stallion
Wed 26th Apr '00, 6:18am
It'd probably be best to use the PHP GETNUMROWS command, as deleted posts will still be counted if you use the MAX() command on an auto-incrementing table.