can anyone help me mysql problem when i try to fix i cant pfff hope you solve my problem
[/] MTA: San Andreas :: 0/32 players :: 157 resources :: 151 fps (25)
[02:07:13] ERROR: Couldn't find resource pwnage. Check it exists.
[02:07:13] ERROR: Couldn't find resource cinema. Check it exists.
[02:07:13] Creating new DB table vending_machines
[02:07:13] ERROR: Couldn't find resource changename-system. Check it exists.
[02:07:13] Querying MTA master server... success! (Auto detected IP:154.109.159.
190)
[02:07:13] Authorized serial account protection is enabled for the ACL group(s):
`Admin` See https://mtasa.com/authserial
[02:07:13] WARNING: <owner_email_address> not set
[02:07:13] Server started and is ready to accept connections!
[02:07:13] To stop the server, type 'shutdown' or press Ctrl-C
[02:07:13] Type 'help' for a list of commands.
[02:07:13] Stopping global
[02:07:13] Starting global
[02:07:13] ERROR: mysql\connection.lua:62: attempt to call global 'mysql_ping' (
a nil value)
[02:07:13] ERROR: global\money_globals.lua:26: call: failed to call 'mysql:query
' [string "?"]
[02:07:13] ERROR: mysql\connection.lua:62: attempt to call global 'mysql_ping' (
a nil value)
[02:07:13] ERROR: global\money_globals.lua:37: call: failed to call 'mysql:query
' [string "?"]
[02:07:13] global restarted successfully
thease my sql
--[[
MMR
]]
local connection = nil
local connection = nil
local null = nil
local results = { }
local max_results = 128
-- connection functions
local function connect( )
-- retrieve the settings
local server = "192.168.8.100"
local user = "678_basespielers"
local password = "basemed"
local db = "678_basespielers"
local port = get( "port" ) or 3306
local socket = get( "socket" ) or nil
-- connect
connection = mysql_connect ( server, user, password, db, port, socket )
if connection then
if user == "root" then
setTimer( outputDebugString, 100, 1, "Connecting to your MySQL as 'root' is strongly discouraged.", 2 )
end
return true
else
outputDebugString ( "Connection to MySQL Failed.", 1 )
return false
end
end
local function disconnect( )
if connection and mysql_ping( connection ) then
mysql_close( connection )
end
end
local function checkConnection( )
if not connection or not mysql_ping( connection ) then
return connect( )
end
return true
end
addEventHandler( "onResourceStart", resourceRoot,
function( )
if not mysql_connect then
if hasObjectPermissionTo( resource, "function.shutdown" ) then
shutdown( "MySQL module missing." )
end
cancelEvent( true, "MySQL module missing." )
elseif not hasObjectPermissionTo( resource, "function.mysql_connect" ) then
if hasObjectPermissionTo( resource, "function.shutdown" ) then
shutdown( "Insufficient ACL rights for mysql resource." )
end
cancelEvent( true, "Insufficient ACL rights for mysql resource." )
elseif not connect( ) then
if connection then
outputDebugString( mysql_error( connection ), 1 )
end
if hasObjectPermissionTo( resource, "function.shutdown" ) then
shutdown( "MySQL failed to connect." )
end
cancelEvent( true, "MySQL failed to connect." )
else
null = mysql_null( )
end
end
)
addEventHandler( "onResourceStop", resourceRoot,
function( )
for key, value in pairs( results ) do
mysql_free_result( value.r )
outputDebugString( "Query not free()'d: " .. value.q, 2 )
end
disconnect( )
end
)
--
function escape_string( str )
if type( str ) == "string" then
return mysql_escape_string( connection, str )
elseif type( str ) == "number" then
return tostring( str )
end
end
local function query( str, ... )
checkConnection( )
if ( ... ) then
local t = { ... }
for k, v in ipairs( t ) do
t[ k ] = escape_string( tostring( v ) ) or ""
end
str = str:format( unpack( t ) )
end
local result = mysql_query( connection, str )
if result then
for num = 1, max_results do
if not results[ num ] then
results[ num ] = { r = result, q = str }
return num
end
end
mysql_free_result( result )
return false, "Unable to allocate result in pool"
end
return false, mysql_error( connection )
end
function query_free( str, ... )
if sourceResource == getResourceFromName( "runcode" ) then
return false
end
checkConnection( )
if ( ... ) then
local t = { ... }
for k, v in ipairs( t ) do
t[ k ] = escape_string( tostring( v ) ) or ""
end
str = str:format( unpack( t ) )
end
local result = mysql_query( connection, str )
if result then
mysql_free_result( result )
return true
end
return false, mysql_error( connection )
end
function free_result( result )
if results[ result ] then
mysql_free_result( results[ result ].r )
results[ result ] = nil
end
end
function query_assoc( str, ... )
if sourceResource == getResourceFromName( "runcode" ) then
return false
end
local t = { }
local result, error = query( str, ... )
if result then
for result, row in mysql_rows_assoc( results[ result ].r ) do
local num = #t + 1
t[ num ] = { }
for key, value in pairs( row ) do
if value ~= null then
t[ num ][ key ] = tonumber( value ) or value
end
end
end
free_result( result )
return t
end
return false, error
end
function query_assoc_single( str, ... )
if sourceResource == getResourceFromName( "runcode" ) then
return false
end
local t = { }
local result, error = query( str, ... )
if result then
local row = mysql_fetch_assoc( results[ result ].r )
if row then
for key, value in pairs( row ) do
if value ~= null then
t[ key ] = tonumber( value ) or value
end
end
free_result( result )
return t
end
free_result( result )
return false
end
return false, error
end
function query_insertid( str, ... )
if sourceResource == getResourceFromName( "runcode" ) then
return false
end
local result, error = query( str, ... )
if result then
local id = mysql_insert_id( connection )
free_result( result )
return id
end
return false, error
end
function query_affected_rows( str, ... )
if sourceResource == getResourceFromName( "runcode" ) then
return false
end
local result, error = query( str, ... )
if result then
local rows = mysql_affected_rows( connection )
free_result( result )
return rows
end
return false, error
end
next layout
--[[
MMR
]]
local allowUpdate = get( 'auto_update' ) ~= 0 -- change this setting to 0 to only print the required queries to console but not actually change stuff, removing it or setting it to anything but 0 leaves it enabled
--
local query_update = nil
if allowUpdate then
query_update = query_free
else
query_update = function( str, ... )
if ( ... ) then
local t = { ... }
for k, v in ipairs( t ) do
t[ k ] = escape_string( tostring( v ) ) or ""
end
str = str:format( unpack( t ) )
end
outputServerLog( str )
return true
end
end
local function getColumnString( value )
local str = "`" .. escape_string( value.name ) .. "` " .. escape_string( value.type )
if not value.null then
str = str .. " NOT NULL"
end
if value.default then
if value.default == 'CURRENT_TIMESTAMP' then
str = str .. " DEFAULT CURRENT_TIMESTAMP"
else
str = str .. " DEFAULT '" .. escape_string( tostring( value.default ) ) .. "'"
end
end
if value.auto_increment then
str = str .. " AUTO_INCREMENT"
end
return str
end
function create_table( name, columns )
if sourceResource == getResourceFromName( "runcode" ) then
return false
end
if not query_assoc_single( "SHOW TABLES LIKE '%s'", name ) then
-- try to create the missing table
local cols = { }
local keys = { }
local autoIncrementValue = ""
for key, value in pairs( columns ) do
if value.primary_key then
table.insert( keys, "`" .. escape_string( value.name ) .."`" )
end
if type( value.auto_increment ) == "number" then
autoIncrementValue = " AUTO_INCREMENT=" .. value.auto_increment
end
table.insert( cols, getColumnString( value ) )
end
if #keys > 0 then
table.insert( cols, "PRIMARY KEY (" .. table.concat( keys, ", " ) .. ")" )
end
if query_update( "CREATE TABLE `%s`(\n " .. table.concat( cols, ",\n " ) .. "\n) ENGINE=MyISAM" .. autoIncrementValue, name ) then
outputDebugString( "Created table " .. name, 3 )
return true, true
else
outputDebugString( "Unable to create table " .. name, 1 )
return false
end
else
-- make sure all columns do exist
local result = query_assoc( 'DESCRIBE ' .. name )
local fields = { }
local primary_keys = { }
local has_primary_key = false
local change_primary_keys = false
for key, value in pairs( result ) do
fields[ value.Field ] = { name = value.Field, type = value.Type, null = value.Null == "YES", auto_increment = value.Extra == "auto_increment", primary_key = value.Key == 'PRI' or nil, default = value.Default }
if value.Key == 'PRI' then
has_primary_key = true
end
end
local insertWhere = "FIRST"
for key, value in ipairs( columns ) do
if not fields[ value.name ] then
if query_update( "ALTER TABLE `%s` ADD " .. getColumnString( value ) .. " " .. insertWhere, name ) then
outputDebugString( "Created column " .. name .. "." .. value.name, 3 )
else
outputDebugString( "Unable to create column " .. name .. "." .. value.name, 1 )
return false
end
else
-- let's check if everything is alright
local f = fields[ value.name ]
local str = getColumnString( value )
if getColumnString( f ) ~= str then
if query_update( "ALTER TABLE `%s` MODIFY COLUMN " .. str, name ) then
outputDebugString( "Changed field " .. name .. "." .. value.name, 3 )
else
outputDebugString( "Changing field " .. name .. "." .. value.name .. " failed", 1 )
return false
end
end
-- verify our primary keys
if value.primary_key then
table.insert( primary_keys, "`" .. escape_string( value.name ) .."`" )
end
if f.primary_key ~= value.primary_key then
change_primary_keys = true
end
end
insertWhere = "AFTER `" .. escape_string( value.name ) .. "`"
end
-- change the primary key if we have to
if change_primary_keys then
outputDebugString( "Changing primary keys...", 3 )
if has_primary_key then
if #primary_keys == 0 then
if not query_update( "ALTER TABLE `%s` DROP PRIMARY KEY", name ) then
outputDebugString( "Unable to drop primary key", 1 )
return false
end
else
if not query_update( "ALTER TABLE `%s` DROP PRIMARY KEY, ADD PRIMARY KEY(" .. table.concat( primary_keys, ", " ) .. ")", name ) then
outputDebugString( "Unable to change primary key", 1 )
return false
end
end
elseif #primary_keys > 0 then
if not query_update( "ALTER TABLE `%s` ADD PRIMARY KEY(" .. table.concat( primary_keys, ", " ) .. ")", name ) then
outputDebugString( "Unable to add new primary key", 1 )
return false
end
end
end
return true, false
end
end