Skip to content

OnMySQLError

imshooter edited this page Oct 24, 2026 · 1 revision

A query failed, before its public is called.

public OnMySQLError(MySQL:handle, errorid, const error[], const query[], const callback[])

Parameters

Parameter Description
MySQL:handle Handle it was sent through.
errorid Error number of MySQL.
const error[] Message of the error.
const query[] Start of the query, up to 1024 characters.
const callback[] Public of the query, empty when it has none.

Remarks

It is called in the script that sent the query, for every query, statement and batch that fails, also those sent without a public and those waited for, before the public of the query. The component also logs the error, unless log_errors is off. See Errors.

Example

public OnMySQLError(MySQL:handle, errorid, const error[], const query[], const callback[]) {
    new
        line[256]
    ;

    format(line, sizeof (line), "MySQL error %i in %s: %s", errorid, callback[0] != EOS ? callback : ("a query without a public"), error);

    for (new i; i != MAX_PLAYERS; ++i) {
        if (IsPlayerConnected(i) && IsPlayerAdmin(i)) {
            SendClientMessage(i, -1, line);
        }
    }

    return 1;
}

Related

Clone this wiki locally