--- title: "Configure Error and Warning Handling Using the SQLSRV Driver | Microsoft Docs" ms.custom: "" ms.date: "03/26/2018" ms.prod: sql ms.prod_service: connectivity ms.reviewer: "" ms.technology: connectivity ms.topic: conceptual helpviewer_keywords: - "errors and warnings" ms.assetid: 257c6f53-9137-4619-a613-eee33d2077e8 author: David-Engel ms.author: v-daenge --- # How to: Configure Error and Warning Handling Using the SQLSRV Driver [!INCLUDE[Driver_PHP_Download](../../includes/driver_php_download.md)] This topic describes how to configure the SQLSRV driver to handle errors and warnings. By default, the SQLSRV driver treats warnings as errors; a call to a **sqlsrv** function that generates an error or a warning returns **false**. To disable this behavior, use the [sqlsrv_configure](../../connect/php/sqlsrv-configure.md) function. When the following line of code is included at the beginning of a script, a **sqlsrv** function that generates only warnings (no errors) will not return **false**: `sqlsrv_configure("WarningsReturnAsErrors", 0);` The following line of code resets the default behavior (warnings are treated as errors): `sqlsrv_configure("WarningsReturnAsErrors", 1);` > [!NOTE] > Warnings that correspond to SQLSTATE values 01000, 01001, 01003, and 01S02 are never treated as errors. Regardless of the configuration, a **sqlsrv** function that generates only warnings that correspond to one of these states will not return **false**. The value for **WarningsReturnAsErrors** can also be set in the php.ini file. For example, this entry in the `[sqlsrv]` section of the php.ini file turns off the default behavior. `sqlsrv.WarningsReturnAsErrors = 0` For information about retrieving error and warning information, see [sqlsrv_errors](../../connect/php/sqlsrv-errors.md) and [How to: Handle Errors and Warnings](../../connect/php/how-to-handle-errors-and-warnings-using-the-sqlsrv-driver.md). ## Example The following code example demonstrates how to disable the default error-handling behavior. The example uses the Transact-SQL PRINT command to generate a warning. For more information about the PRINT command, see [PRINT (Transact-SQL)](../../t-sql/language-elements/print-transact-sql.md). The example first demonstrates the default error-handling behavior by executing a query that generates a warning. This warning is treated as an error. After changing the error-handling configuration, the same query is executed. The warning is not treated as an error. The example assumes that SQL Server is installed on the local computer. All output is written to the console when the example is run from the command line. ``` ``` ## See Also [Logging Activity](../../connect/php/logging-activity.md) [Programming Guide for the Microsoft Drivers for PHP for SQL Server](../../connect/php/programming-guide-for-php-sql-driver.md) [SQLSRV Driver API Reference](../../connect/php/sqlsrv-driver-api-reference.md)