Hi,
I'm using PHP to connect to a MS SQL server. I have a file called xxxx.php in which i connect to the sql server using the following code:
$user="xxxxx";
$pass="xxxxxx";
$db="myDatabase";
$server = "xxx.xxx.xxx.xxx";
$link = mssql_connect($server, $user,$pass);
if(! $link) {
die("There was an error connecting to the database.");
}
mssql_select_db($db) or die ("Couldnt open $db: " );
In every php page that I need to use the database i use the line:
inlucde("xxx.php") to include the above file and at the end of the file i use mssql_close($link).
Now my question is that is this the efficient way of doing it? Or is there a way to basically open one connection at the start and somehow use it through out the whole time they are surfing my site? and if thats the case how do i close that connection if they leave the site?
thanks a lot