• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Error in SQL syntax

gabriel28

Member
Joined
Mar 16, 2012
Messages
199
Solutions
6
Reaction score
24
I'm trying to do a function that get the skill value from the database, but I don't have much knowledge about sql, so I need this help. My MySQL version is 5.5


Lua:
function getSkill (cid, skill)
local pid = getPlayerGUID(cid)
db.getResult("SELECT `value` FROM `player_skills` WHERE `player_id` = " ..pid.. " and `skillid` = ".. skill ..",")
return true
end

Thanks in advance.
 
Solution
I'm trying to do a function that get the skill value from the database, but I don't have much knowledge about sql, so I need this help. My MySQL version is 5.5


Lua:
function getSkill (cid, skill)
local pid = getPlayerGUID(cid)
db.getResult("SELECT `value` FROM `player_skills` WHERE `player_id` = " ..pid.. " and `skillid` = ".. skill ..",")
return true
end

Thanks in advance.
I'm not sure what distro you are using but you can try this:
Lua:
function getSkill(cid, skill)
    local result = db.getResult("SELECT `value` FROM `player_skills` WHERE `player_id` = " .. getPlayerGUID(cid) .. " and `skillid` = " .. skill)
    if result:getID() == -1 then
        return
    end
    local skill_value = result:getDataInt('value')...
I'm trying to do a function that get the skill value from the database, but I don't have much knowledge about sql, so I need this help. My MySQL version is 5.5


Lua:
function getSkill (cid, skill)
local pid = getPlayerGUID(cid)
db.getResult("SELECT `value` FROM `player_skills` WHERE `player_id` = " ..pid.. " and `skillid` = ".. skill ..",")
return true
end

Thanks in advance.
I'm not sure what distro you are using but you can try this:
Lua:
function getSkill(cid, skill)
    local result = db.getResult("SELECT `value` FROM `player_skills` WHERE `player_id` = " .. getPlayerGUID(cid) .. " and `skillid` = " .. skill)
    if result:getID() == -1 then
        return
    end
    local skill_value = result:getDataInt('value')
    result:free()
    return skill_value
end
 
Solution
Back
Top