mssql_get_last_message

Returns the last message from the server

Warning

This function was REMOVED in PHP 7.0.0.

Alternatives to this function include:

  • PDOStatement::errorInfo
  • sqlsrv_errors
  • odbc_errormsg

Description

string mssql_get_last_message ( void )

Gets the last message from the MS-SQL server

Parameters

This function has no parameters.

Return Values

Returns last error message from server, or an empty string if no error messages are returned from MSSQL.

Examples

Example #1 mssql_get_last_message example

<?php
// Connect to MSSQL and select the database
mssql_connect('KALLESPC\SQLEXPRESS''sa''phpfi');
mssql_select_db('php');

// Make a query that will fail
$query = @mssql_query('SELECT * FROM [php].[dbo].[not-found]');

if (!
$query) {
    
// The query has failed, print a nice error message
    // using mssql_get_last_message()
    
die('MSSQL error: ' mssql_get_last_message());
}
?>

The above example will output something similar to:

MSSQL error: Invalid object name 'php.dbo.not-found'.

See Also

  • mssql_min_error_severity
  • mssql_min_message_severity