Modules/MTA-MySQL/mysql errno

From Multi Theft Auto: Wiki

Package-x-generic.png This function is provided by the external module MTA-MySQL. You must install this module to use this function.

Returns the last error number of a MySQL connection.


int mysql_errno ( MySQLConnection handler )

Required arguments

  • handler: A valid MySQL link


The last error number, zero if nothing failed. Visit for a list of error codes.


Example 1: This example sends a query to the server and if it fails, shows the reason.

result = mysql_query(handler, "SELECT FROM table") -- We have a syntax error in the query
if (not result) then -- The query failed
  outputDebugString("mysql_query failed: (" .. mysql_errno(handler) .. ") " .. mysql_error(handler)) -- Show the reason
  mysql_free_result(result) -- Free the last query result data

See also