⟩ How To Retrieve Error Messages using mssql_get_last_message()?
When you call mssql_query() to execute a SQL statement, and the execution failed on the SQL Server, you can use mssql_get_last_message() function to retrieve the error messages.
The tutorial script below shows you a good example:
<?php
$con = mssql_connect('LOCALHOST','sa','GlobalGuideLine');
mssql_select_db('GlobalGuideLineDatabase', $con);
# dropping a table
$sql = 'DROP TABLE fyi.center';
$res = mssql_query($sql, $con);
if (!$res) {
print("Execution failed: ");
print(" Error: ".mssql_get_last_message()." ");
} else {
print("Execution was successful. ");
}
mssql_close($con);
?>