• 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!

mysql problem with new "points"

vexler222

Active Member
Joined
Apr 22, 2012
Messages
714
Solutions
15
Reaction score
46
Hi, i have problem with this script

Code:
local cfg = {
    points = 1,
    effect = CONST_ME_GIFT_WRAPS
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition, name)
    if not isPlayer(cid) then
        return false
    end
 
    db.executeQuery("UPDATE 'players' SET 'new_point' = 'new_point + 1' WHERE 'name' = '.. getCreatureName(cid)..''';")
    doCreatureSay(cid, "+1", TALKTYPE_ORANGE_1)
    doSendMagicEffect(toPosition, cfg.effect)
    doRemoveItem(item.uid, 1)
    return true
end

I was try add new points, i have new collumn in database "new_points" in players section but it dont adding points after use item... But in console i have error

Code:
[20:32:48.432] mysql_real_query(): UPDATE 'players' SET 'new_point' = 'new_point + 1' WHERE 'name' = '.. getCreatureName(cid)..'''; - MYSQL ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''players' SET 'new_point' = 'new_point + 1' WHERE 'name' = '.. getCreatureName(cid)...' at line 1 (1064)


I dont understand mysql so i try edit a premium points rune but i need add points only for one character not account
 
Solution
Before and after table names and column names you must use this letter ` , not '
and strings must be 'escaped' to make them secure (not hack your database).
So your query should look like:
Code:
db.executeQuery("UPDATE `players` SET `new_point` = `new_point` + 1 WHERE `name` = '.. db.escapeString(getCreatureName(cid)))
Before and after table names and column names you must use this letter ` , not '
and strings must be 'escaped' to make them secure (not hack your database).
So your query should look like:
Code:
db.executeQuery("UPDATE `players` SET `new_point` = `new_point` + 1 WHERE `name` = '.. db.escapeString(getCreatureName(cid)))
 
Solution
Thanks bro, it work but i must replace ' with "
I don't know why ' not work but nvm :D

here:
Code:
'.. db.escapeString(getCreatureName(cid)))
 
Back
Top