Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.
GTAONLINE.PL
Tematy otagowane jako: mysql_ping
1. Baza danych mysql_ping
Witam, od jakiegos czasu ciagle wyskakuje mi error w DB3 o tresci:
[code]ERROR:[pystories]/[skrypty]/DB/sql.lua:31: bad argument #1 to "mysql_ping" (mysqlHandler expected, got nil)[/code]

Uprzedzam pytania mam wgrany modul mta_mysql.so

sql.lua
[lua]
local SQL_LOGIN="****"
local SQL_PASSWD="****"
local SQL_DB="****"
local SQL_HOST="*****"
local SQL_PORT=*****

local root = getRootElement()

local SQL

local function connect()
SQL = mysql_connect(SQL_HOST, SQL_LOGIN, SQL_PASSWD, SQL_DB, SQL_PORT)
if (not SQL) then
outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
else
mysql_query(SQL,"SET NAMES utf8")
end

end


local function keepAlive()
if (not mysql_ping(SQL)) then
outputServerLog("Zerwane polaczenie z baza danych, nawiazywanie...")
connect()
end
end

addEventHandler("onResourceStart",getResourceRootElement(),function()
connect()
setTimer(keepAlive, 30000, 0)
end)

function esc(value)
return mysql_escape_string(SQL,value)
end

function pobierzTabeleWynikow(query)
local result=mysql_query(SQL,query)
if (not result) then
outputDebugString("mysql_query failed: (" .. mysql_errno(SQL) .. ") " .. mysql_error(SQL)) -- Show the reason
return nil
end
local tabela={}
for result,row in mysql_rows_assoc(result) do
table.insert(tabela,row)
end
mysql_free_result(result)
return tabela
end

...