Connection Function/Class
Posted: Fri Apr 13, 2012 10:41 am
Below is how i am connecting to my database. I do this on every page.
My question is how do make this into a function of some sorts. And how do i call it on each page
BTW i will be using the variable $cconn when i do queries and things how would i make it so this variable is accessible to use on every page (i.e Make it a global variable)
Thanks in advance
Code: Select all
$cdatabase = 'XXXXXXX;
$cUID = 'XXXXXX';
$cPWD = 'XXXXXX';
$cSRVname = 'XXXXXXX';
$cconnectionInfo = array("Database" => $cdatabase, "UID" => $cUID, "PWD" => $cPWD);
$cconn = sqlsrv_connect($cSRVname, $cconnectionInfo);BTW i will be using the variable $cconn when i do queries and things how would i make it so this variable is accessible to use on every page (i.e Make it a global variable)
Thanks in advance