Wysłany: 2014-03-09, 11:23
Drak
Wiek: 34 Na forum: 4903 dni Posty: 71
Nick w MP: Drak
Piwa : 3
Witam! Mam problem z executeSQLInsert . Problem Ten polega na tym, ?e podczas rejestracji nie uzupe?nia si? baza danych, gdy? wyskakuje b??d, ?e ma ona 6 tabel a chc? zdefiniowa? 8 warto?ci.
Kod:
function registerYes ( name , pass )
if not getAccount ( name ) then
local ac = addAccount ( name , pass )
if ac then
local res = executeSQLSelect ( "Zombie_Mod_Accounts" , "cash, kills, death, xp, lvl" , "ac='" .. name .. "'" )
if #res == 0 then
executeSQLInsert ( "Zombie_Mod_Accounts" , "'" .. name .. "', 100, 0, 0, 0, 1,'',''" )
logIn ( source , getAccount ( name , pass ), pass )
triggerClientEvent ( source , "registerOk" , source )
else
local text = "B??d w czasie tworzenia konta."
triggerClientEvent ( source , "errInfo" , source , text )
end
else
local text = "Nieznany b??d."
triggerClientEvent ( source , "errInfo" , source , text )
end
else
local text = "Konto o takim loginie ju? istnieje."
triggerClientEvent ( source , "errInfo" , source , text )
end
end
addEvent ( "registerYes" , true )
addEventHandler ( "registerYes" , getRootElement (), registerYes )
Co jest ?le w tym kodzie? Co zrobi? aby to dzia?a?o?
Wysłany: 2014-03-09, 12:31
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
Po pierwsze, tej funkcji si? ju? nie u?ywa, bo jak samo wiki napisa?o 'This function is deprecated'. Zamiast tego u?yj executeSQLQuery.
Po drugie, widz?, ?e te? u?ywasz executeSQLSelect - tego te? si? nie u?ywa. Teraz g??wnie w SQL u?ywa si? tylko executeSQLQuery.
executeSQLQuery ( "INSERT INTO nazwaTabeli (kolumna1, kolumna2, kolumna3) VALUES(warto??1, warto??2, warto??3)" , w1 , w2 , 3 )
Tak dla przyk?adu.
Wysłany: 2014-03-09, 13:49
Drak
Wiek: 34 Na forum: 4903 dni Posty: 71
Nick w MP: Drak
Piwa : 3
Nie zauwa?y?em, ?e te funkcje s? nie aktualne, ale to nic.
Zmieni?em wszystkie funkcje SQL na executeSQLQuery i mam inny problem. W bazie zapisuje si? wszystko co chcia?em, lecz nie przypisane do ?adnego konta. Tabela ac jest pusta.
Kod:
function registerYes ( name , pass )
if not getAccount ( name ) then
local ac = addAccount ( name , pass )
if ac then
local res = executeSQLQuery ( "SELECT cash, kills, death, xp, lvl FROM Zombie_Mod_Accounts WHERE ac=?" )
if #res == 0 then
executeSQLQuery ( "INSERT INTO Zombie_Mod_Accounts(cash, kills, death, xp, lvl) VALUES(100, 0, 0, 0, 1)" , cash , kills , death , xp , lvl )
logIn ( source , getAccount ( name , pass ), pass )
triggerClientEvent ( source , "registerOk" , source )
else
local text = "B??d w czasie tworzenia konta."
triggerClientEvent ( source , "errInfo" , source , text )
end
else
local text = "Nieznany b??d."
triggerClientEvent ( source , "errInfo" , source , text )
end
else
local text = "Konto o takim loginie ju? istnieje."
triggerClientEvent ( source , "errInfo" , source , text )
end
end
addEvent ( "registerYes" , true )
addEventHandler ( "registerYes" , getRootElement (), registerYes )
Zapomnia?em czego? w kodzie? Jak to naprawi??
Ps. Jacob , dzi?kuje za poinformowanie mnie o tych funkcjach.
Wysłany: 2014-03-09, 14:06
Jacob
Głupiomądry
Wiek: 28 Na forum: 5502 dni Posty: 967
Nick w MP: Jacob
Piwa : 786
Wi?c tak.
My?la?em, ?e to umiesz, ale widz?, ?e nie. Chodzi o to, ?e musisz zdefiniowa? gdzie te dane maj? zosta? umieszczone
executeSQLQuery ( "INSERT INTO Zombie_Mod_Accounts(cash, kills, death, xp, lvl) VALUES(100, 0, 0, 0, 1) WHERE ac=?" , cash , kills , death , xp , lvl , account )
I jeszcze jednego ac nie zdefiniowa?e?, mianowicie tutaj:
executeSQLQuery ( "SELECT cash, kills, death, xp, lvl FROM Zombie_Mod_Accounts WHERE ac=?" )
Powinno by?
executeSQLQuery ( "SELECT cash, kills, death, xp, lvl FROM Zombie_Mod_Accounts WHERE ac=?" , zdefiniowane_konto )
Wysłany: 2014-03-09, 14:53
Drak
Wiek: 34 Na forum: 4903 dni Posty: 71
Nick w MP: Drak
Piwa : 3
Dzi?kuje za pomoc. Wszystko ju? dzia?a. leci
Tagi: executesqlinsert :: działa :: niepoprawnie
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: