LinChang
12-09-2010, 11:49 PM
Ok so I am creating a custom page, everything went well but am stuck on one little issue, that is how do i establish connection to database in vBulletin 4.x, I know how to establish database connection but I just want to know if their is any built in function in vbulletin 4.x that does the connection to establishment automatically. Below is my demo code, scroll down the the very bottom in red is where I showed a example where I said mysql_query($sql) but before I can do that I first need to connect to database. Anyone know the answer?
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'test');
define('CSRF_PROTECTION', true);
// change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array('films',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$navbits = construct_navbits(array('' => 'Asia Films'));
$navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE #####
How does vBulletin 4.x establish the mysql connection? so that my mysql_query below will be able to connect to the database and grab the stuff
$variable = mysql_query($sql)or die();
//Below is the code that I am going to use to manipulate the returned mysql query.
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('films');
$templater->register_page_templates();
$templater->register('headcustom', $headcustom);
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('page', $page);
print_output($templater->render());
// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
// #################### DEFINE IMPORTANT CONSTANTS #######################
define('THIS_SCRIPT', 'test');
define('CSRF_PROTECTION', true);
// change this depending on your filename
// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();
// get special data templates from the datastore
$specialtemplates = array();
// pre-cache templates used by all actions
$globaltemplates = array('films',
);
// pre-cache templates used by specific actions
$actiontemplates = array();
// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');
// ################################################## #####################
// ######################## START MAIN SCRIPT ############################
// ################################################## #####################
$navbits = construct_navbits(array('' => 'Asia Films'));
$navbar = render_navbar_template($navbits);
// ###### YOUR CUSTOM CODE GOES HERE #####
How does vBulletin 4.x establish the mysql connection? so that my mysql_query below will be able to connect to the database and grab the stuff
$variable = mysql_query($sql)or die();
//Below is the code that I am going to use to manipulate the returned mysql query.
// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
$templater = vB_Template::create('films');
$templater->register_page_templates();
$templater->register('headcustom', $headcustom);
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('page', $page);
print_output($templater->render());