MS SQL Server Concepts and Programming Question:
Download Questions PDF

How To Disconnect from a SQL Server using mssql_close()?


When you call mssql_connect(), it will return an object representing the connection to the SQL Server. This connection object will be used by subsequent MSSQL function calles. When you are done with this connection, you should close it to free up resources by calling the mssql_close() function.

The tutorial script below shows you how to call mssql_connect() and mssql_close() to connect and disconnect to the SQL Server:

$con = mssql_connect('LOCALHOST','sa','GlobalGuideLine');
if (!$con) {
print("Connection failed with error. ");
} else {
print("The SQL Server connection object is ready. ");

If you run this script and get this output: "The SQL Server connection object is ready", your connection to the SQL Server are working.

Note that 'sa' and 'GlobalGuideLine' used in this script are system administrator login name and password. You may use any other login name and password defined on the SQL Server.

Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
What Are Commonly Used MSSQL Functions in PHP?How To Select an Exiting Database using mssql_select_db()?