# mysql\_errno

## Syntax

```c
unsigned int mysql_errno(MYSQL * mysql);
```

* `mysql` - a mysql handle, which was previously allocated by [mysql\_init()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_init) or [mysql\_real\_connect()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_real_connect).

## Description

Returns the last [error code](https://app.gitbook.com/s/SsmexDFPv2xG2OTyO5yV/reference/error-codes) for the most recent function call that can succeed or fail. Zero means no error occurred.

{% hint style="info" %}
Client error messages are listed in errmsg.h header file, server error messages are listed in mysqld\_error.h header file of the server source distribution.
{% endhint %}

## See also

* [mysql\_error()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_error)
* [mysql\_sqlstate()](https://mariadb.com/docs/connectors/mariadb-connector-c/api-functions/mysql_sqlstate)

{% @marketo/form formId="4316" %}
