Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - Programming » SQL Anywhere PHP API » SQL Anywhere PHP API reference

sqlanywhere_error Next Page

sqlanywhere_errorcode


Prototype

bool sqlanywhere_errorcode( [ resource link_identifier ] )

Description

Returns the error code of the most-recently executed SQL Anywhere PHP function. Error codes are stored per connection. If no link_identifier is specified, then sqlanywhere_errorcode returns the last error code where no connection was available. For example, if you are calling sqlanywhere_connect and the connection fails, then call sqlanywhere_errorcode with no parameter for the link_identifier to get the error code. If you want to get the corresponding error message use the sqlanywhere_error function.

Parameters

link_identifier    A link identifier that was returned by sqlanywhere_connect or sqlanywhere_pconnect.

Returns

An integer representing a SQL Anywhere error code. An error code of 0 means success. A positive error code indicates success with warnings. A negative error code indicates failure.

Example

This example shows how you can retrieve the last error code from a failed SQL Anywhere PHP call.

$result = sqlanywhere_query( $conn, "SELECT * from table_that_does_not_exist" );
   if( ! $result ) {
       $error_code = sqlanywhere_errorcode( $conn );
       echo "Query failed: Error code: $error_code";
   }
Related functions