Wysłany: 2018-02-09, 17:07
KuB3k
grafika/muzyka
Wiek: 21 Na forum: 3415 dni Posty: 52
Piwa : 720
Witam, to ju? m?j drugi post dzisiaj prosz?cy o pomoc.
Przecho uda?o mi si? naprawi?, ale teraz db nie chce dzia?a?.
SS: https://imgur.com/a/Dq9BC
Wysłany: 2018-02-09, 17:31
Nexisten
Moderator
Wiek: 22 Na forum: 4107 dni Posty: 551
Nick w MP: Nexisten
Piwa : 1479
Podaj ca?? zawarto?? pliku s_db.lua w znacznikach [ lua ]
Wysłany: 2018-02-09, 17:38
KuB3k
grafika/muzyka
Wiek: 21 Na forum: 3415 dni Posty: 52
Piwa : 720
"vNeXxuS" napisał/a :Podaj ca?? zawarto?? pliku s_db.lua w znacznikach [ lua ]
(WSZYSTKO MAM POD??CZONE ALE USUN??EM ?EBY?CIE SI? NIE W?AMALI xd)
-- Settings
DBHandler = nil
DBName = "/"
DBUser = "/"
DBPass = "/"
DBHost = "/"
-- Functions
function dbSet (...)
if not {...} then return end
local stringe = dbPrepareString ( DBHandler ,...)
local query = dbExec ( DBHandler , stringe )
return query
end
function dbGet (...)
if not {...} then return end
local stringe = dbPrepareString ( DBHandler ,...)
local query = dbQuery ( DBHandler , stringe )
local result = dbPoll ( query , - 1 )
return result
end
addEventHandler ( "onResourceStart" , resourceRoot , function()
DBHandler = dbConnect ( "mysql" , "dbname=" .. DBName .. ";host=" .. DBHost .. "" , DBUser , DBPass , "share=1;autoreconnect=1" )
if DBHandler then
outputDebugString ( "* Connect to server MYSQL..." )
dbSet ( "SET NAMES utf8" )
else
outputDebugString ( "* No Connecting to server MYSQL.." )
end
end )
local SQL_LOGIN = "/"
local SQL_PASSWD = "/"
local SQL_DB = "/"
local SQL_HOST = "/"
local SQL_PORT = 3306
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" )
-- outputServerLog ( "Modul mysql polaczony!" )
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 ))
outputServerLog ( "mysql_query failed: (" .. mysql_errno ( SQL ) .. ") " .. mysql_error ( SQL ))
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
function pobierzWyniki ( query )
local result = mysql_query ( SQL )
if ( not result ) then return nil end
row = mysql_fetch_assoc ( result )
mysql_free_result ( result )
return row
end
function zapytanie ( query )
local result = mysql_query ( SQL , query )
if ( result ) then mysql_free_result ( result ) return true end
return
end
function insertID ()
return mysql_insert_id ( SQL )
end
function affectedRows ()
return mysql_affected_rows ( SQL )
end
function fetchRows ( query )
local result = mysql_query ( SQL , query )
if ( not result ) then return nil end
local tabela ={}
while true do
local row = mysql_fetch_row ( result )
if ( not row ) then break end
table . insert ( tabela , row )
end
mysql_free_result ( result )
return tabela
end
function getSQLLink ()
return SQL
end
local mysql = false
function polacz ()
mysql = dbConnect ( "mysql" , "dbname=/;host=/" , "/" , "/" , "share=1" )
if not mysql then
outputDebugString ( "Nie udalo polaczyc sie z baza danych." )
else
outputDebugString ( "Udalo polaczyc sie z baza danych." )
end
end
addEventHandler ( "onResourceStart" , resourceRoot , polacz )
function wykonaj (...)
local qh = dbQuery ( mysql , ...)
if not qh then return false end
local result , num_affected_rows , last_insert_id = dbPoll ( qh , - 1 )
return result , num_affected_rows , last_insert_id
end
Wysłany: 2018-02-09, 19:28
Ciastuuś
Truck soon...
Wiek: 26 Na forum: 3071 dni Posty: 799
Nick w MP: Ciastuuś
Piwa : 4297
Podaj b??dy z /debugscript 3. Druga sprawa, posiadasz modu?y?
Tagi: nie :: chce :: działać.
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: