• 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 Errors while trying to db.storeQuery. HEELP!

darkshin

New old member
Joined
Dec 14, 2010
Messages
231
Reaction score
22
Hey Guys!!

I am in trouble while trying to store a database query. They function variables "guid" and "key" are beign rejected by the function saying:
If they are set to numbers:
"attempt to call local "guid" <a number value>"

If they are set to strings:
"attempt to call local "guid" <a string value>"

How can I make this work?

Code:
function getStorageValueByGuid(guid, key)
---LOCALS
    local stringGuid = tostring(guid) //whatever tonumber or tostring
    local stringKey = tonumber(key) //whatever tonumber or tostring
---LOCALS
    print(stringGuid, stringKey)
  
    local resultId = db.storeQuery("SELECT `value` FROM `player_storage` WHERE `player_storage`.`player_id` = " .. guid " AND `player_storage`.`key` = " .. stringKey";")
  
    if resultId ~= false or resultId ~= 0 then
        local Finalvalue = result.getDataInt(resultId, "value")
        print("value:", Finalvalue)
        result.free(resultId)
        return Finalvalue
    else
        print("result: fail")
        return 0
    end
  
end
 
Try this.
Code:
db.storeQuery("SELECT `value` FROM `player_storage` WHERE `player_storage`.`player_id` = "..guid.." AND `player_storage`.`key` = "..stringKey..";")

The problem isn't in sql query as you see.

"..guid.." instead of "..guid"
 
Back
Top