Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2018-01-08, 16:17


Fokus243

dzban






Wiek: 25
Na forum: 3835 dni
Posty: 38
Nick w MP: randis

Piwa: 37

Respekt: 60

hej, mam problem z po??czeniem bazy danych, a dok?adnie wyskakuje mi ca?y czas taki b??d:

ERROR: Loading script failed: [skrypty_Glowne]/ogrpg-db/s_db.lua:11: '=' expected near "DBUser"

oraz taki:

WARNING: [skrypty_glowne]/DB2/sql.lua:16: Bad usage @ "dbConnect" [Can't connect to MySQL server on 213.***.**.***]

usuwa?em ten znak, ale to nie pomaga?o

jak co? to daje kod

Kod:

--[[
Resource: OURGame v2
Developers: Split <split.programista@gmail.com>
You have no right to use this code without my permission.
(c) 2015 <split.programista@gmail.com>. All rights reserved.
]]

-- Settings
DBHandler=nil
DBName="db_16898" nazwa
DBUser="******" login
DBPass="*****" haslo
DBHost="213.***.**.**" host

-- Functions
function dbSet(...)
if not {...} then return end
local qh = dbQuery(DBHandler, ...)
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

function dbGet(...)
if not {...} then return end
local stringe=dbPrepareString(DBHandler,...)
local query=dbQuery(DBHandler, stringe)
local result,num_affected_rows, last_insert_id =dbPoll(query, -1)
return result
end


addEventHandler("onResourceStart", resourceRoot, function()
DBHandler=dbConnect("mysql", "dbname=db_16898", ";host=213.***.**.***", "213.***.**.***", "******","******", "share=1;autoreconnect=1")
if DBHandler then
outputDebugString("* Po??czono pomy?lnie! (MySQL)")
dbSet("SET NAMES utf8")
else
outputDebugString("* Brak po??czenia! (MySQL)")
end
end)


local SQL_LOGIN="******"
local SQL_PASSWD="******"
local SQL_DB="db_16898"
local SQL_HOST="213.***.**.***"
local SQL_PORT=3306

local root = getRootElement()

local SQL

local function connect()
SQL = mysql_connect("SQL_HOST = 213.***.**.***", "SQL_LOGIN = ******", "SQL_PASSWD = ******", "SQL_DB = db_16898", "SQL_PORT = 3306")
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 q(sQuery, ...)
local qHandler=dbQuery(CDatabase.hCon, sQuery, ...)
local result, iRows, sError=dbPoll(qHandler, 90)
if result==nil then
result, iRows, sError=dbPoll(qHandler, -1)
if result==nil then
dbFree(qHandler)
outputDebugString('Max query runtime reached: ' ..sQuery.. '|' ..iRows.. '|' ..sError)
return false
end
end
if result==false then
outputDebugString('Error executing query: ' ..sQuery.. '|' ..iRows.. '|' ..sError)
return false
end
return result, iRows, (sError or '-')
end

function pobierzWyniki(query)
local result=mysql_query(SQL,query)
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


Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-01-09, 14:47


DevJumpDj

VILLAGE MTA






Wiek: 27
Na forum: 3475 dni
Posty: 102
Nick w MP: D4NTE

Piwa: 3277

Respekt: 121
Respekt: 121

Musisz wype?ni? to danymi do logowania do bazy danych. zamiast tych gwiazdek dodaj login, haslo, host.

Czy wgra?e? ju? tabel? do bazy danych 'db_16898' ?

i w?a?nie w tym miejscu:

 -- Settings
DBHandler=nil
DBName="db_16898" nazwa
DBUser="******" login
DBPass="*****" haslo
DBHost="213.***.**.**" host 


masz komentarz bez jego rozpocz?cia i by? mo?e dlatego te? wywala b??d.

Dodaj

-- Settings
DBHandler=nil
DBName="db_16898" -- nazwa
DBUser="login" -- login
DBPass="haslo"  -- haslo
DBHost="host" -- host 


Podpis


VILLAGE MTA - www.villagemta.pl
D4NTE Właściciel serwera
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
maksio41
Wysłany: 2018-01-09, 17:02


Fokus243

dzban






Wiek: 25
Na forum: 3835 dni
Posty: 38
Nick w MP: randis

Piwa: 37

Respekt: 60

tabele juz wrzucilem na myPHP

wpisa?em tak jak trzeba i nadal wywala oba b??dy

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-01-09, 18:25


DevJumpDj

VILLAGE MTA






Wiek: 27
Na forum: 3475 dni
Posty: 102
Nick w MP: D4NTE

Piwa: 3277

Respekt: 121
Respekt: 121

u?yj tego skryptu :
Podmie? ten twoj kod na ten

--[[
    ResourceOURGame v2
    DevelopersSplit <split.programista@gmail.com>
    You have no right to use this code without my permission.
    (c2015 <split.programista@gmail.com>. All rights reserved.
]]

-- Settings
DBHandler=nil
DBName="nazwabazy"
DBUser="login"
DBPass="jakieshaslo"
DBHost="host"

-- Functions
function dbSet(...)
    if not {...} then return end
    local query=dbExec(DBHandler, ...)
    return query
end

function dbGet(...)
    if not {...} then return end
    local query=dbQuery(DBHandler, ...)
    local result=dbPoll(query, -1)
    return result
end

addEventHandler("onResourceStart"resourceRoot, function()
    DBHandler=dbConnect("mysql""dbname="..DBName..";host="..DBHost..""DBUserDBPass"share=1")
    if DBHandler then
        outputDebugString("* Connect to server MYSQL...")
    else
        outputDebugString("* No Connecting to server MYSQL..")
    end
end)


[ Dodano: 2018-01-09, 18:27 ]
Poniewa? zauwa?y?em posiadasz w jednym pliku dwie funkcje kt?re wywo?uj? po??czenie z sql...

Podpis


VILLAGE MTA - www.villagemta.pl
D4NTE Właściciel serwera
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
maksio41
Wysłany: 2018-01-10, 16:56


Fokus243

dzban






Wiek: 25
Na forum: 3835 dni
Posty: 38
Nick w MP: randis

Piwa: 37

Respekt: 60

"DevJumpDj" napisał/a:

u?yj tego skryptu :
Podmie? ten twoj kod na ten

--[[
    ResourceOURGame v2
    DevelopersSplit <split.programista@gmail.com>
    You have no right to use this code without my permission.
    (c2015 <split.programista@gmail.com>. All rights reserved.
]]

-- Settings
DBHandler=nil
DBName="nazwabazy"
DBUser="login"
DBPass="jakieshaslo"
DBHost="host"

-- Functions
function dbSet(...)
    if not {...} then return end
    local query=dbExec(DBHandler, ...)
    return query
end

function dbGet(...)
    if not {...} then return end
    local query=dbQuery(DBHandler, ...)
    local result=dbPoll(query, -1)
    return result
end

addEventHandler("onResourceStart"resourceRoot, function()
    DBHandler=dbConnect("mysql""dbname="..DBName..";host="..DBHost..""DBUserDBPass"share=1")
    if DBHandler then
        outputDebugString("* Connect to server MYSQL...")
    else
        outputDebugString("* No Connecting to server MYSQL..")
    end
end)


[ Dodano: 2018-01-09, 18:27 ]
Poniewa? zauwa?y?em posiadasz w jednym pliku dwie funkcje kt?re wywo?uj? po??czenie z sql...


podmieni?em kod i s? takie b??dy:

w DB2/sql.lua:16: Bad usage dbConnect (Can't connect to MySQL server)

oraz

w ogrpg-db/s_db.lua:30: ')' expected near 'db_16898'

Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-01-10, 18:02


DevJumpDj

VILLAGE MTA






Wiek: 27
Na forum: 3475 dni
Posty: 102
Nick w MP: D4NTE

Piwa: 3277

Respekt: 121
Respekt: 121

?le uzupe?ni?e? dane do logowania z baz? danych.

Podpis


VILLAGE MTA - www.villagemta.pl
D4NTE Właściciel serwera
Postaw piwo autorowi tego posta
 

 
Wysłany: 2018-01-10, 19:14


Fokus243

dzban






Wiek: 25
Na forum: 3835 dni
Posty: 38
Nick w MP: randis

Piwa: 37

Respekt: 60

"DevJumpDj" napisał/a:

?le uzupe?ni?e? dane do logowania z baz? danych.



s_db

--[[
    ResourceOURGame v2
    DevelopersSplit <split.programista@gmail.com>
    You have no right to use this code without my permission.
    (c2015 <split.programista@gmail.com>. All rights reserved.
]]

-- Settings
DBHandler=nil
DBName="db_16898"
DBUser="xxxx"
DBPass="xxxxxxxxx"
DBHost="213.136.71.xxx"

-- Functions
function dbSet(...)
    if not {...} then return end
    local query=dbExec(DBHandler, ...)
    return query
end

function dbGet(...)
    if not {...} then return end
    local query=dbQuery(DBHandler, ...)
    local result=dbPoll(query, -1)
    return result
end

addEventHandler("onResourceStart"resourceRoot, function()
    DBHandler=dbConnect("mysql""dbname="db_16898";host="213.136.71.xxx""xxxxxxxxxxxxx"share=1")
    if DBHandler then
        outputDebugString("* Connect to server MYSQL...")
    else
        outputDebugString("* No Connecting to server MYSQL..")
    end
end)



sql

--[[
Obsluga baz danychinterfejs do bazy MySQL realizowany za pomoca wbudowanych w MTA funkcji db...

@author Lukasz Biegaj <wielebny@bestplay.pl>
@author WUBE <wube@lss-rp.pl>
@copyright 2011-2013 Lukasz Biegaj <wielebny@bestplay.pl>
@license Dual GPLv2/MIT
@package MTA-XyzzyRP
@link https://github.com/lpiob/MTA-XyzzyRP GitHub
]]--

local SQL

local function connect()
    -- w ponizszej linii uzupelnij dane autoryzacji
    SQL dbConnect("mysql""dbname=db_16898;host=213.136.71.xxx""xxxx","xxxxxxxxx","share=1")
    if (not SQLthen
        outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
    else
        zapytanie("SET NAMES utf8;")
    end

end

addEventHandler("onResourceStart",resourceRootconnect)

function pobierzTabeleWynikow(...)
    local h=dbQuery(SQL,...)
    if (not hthen
        return nil
    end
    local rows dbPoll(h, -1)
    return rows
end

function pobierzWyniki(...)
    local h=dbQuery(SQL,...)
    if (not hthen
        return nil
    end
    local rows dbPoll(h, -1)
    if not rows then return nil end
    return rows[1]
end

function zapytanie(...)
    local h=dbQuery(SQL,...)
    local result,numrows=dbPoll(h,-1)
    return numrows
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 resultthen return nil end
    local tabela={}

    while true do
        local row mysql_fetch_row(result)
        if (not rowthen break end
        table.insert(tabela,row)
    end
    mysql_free_result(result)
    return tabela
end


gdzie zle wpisalem ?

Postaw piwo autorowi tego posta
 

 
Tagi: mysql
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku