Reputation: 25
I went from SQLite to MySQL and now I have this issue.. this was not happening with previous SQLite system.. basically what I want is insert a JSON to MySQL, this is the example:
UPDATE stats SET achievements = `[ { "Filthy Rich": "10\/12\/14", "I keep on rollin'": "10\/12\/14" } ]` WHERE account = 'Feche'
And this is the error that I get:
(1054) Unknown column '[ { "Filthy Rich": "10\/12\/14", "I keep on rollin'": "10\/12\/14" } ]' in 'field list'
I've been searching but all answers are for PHP and non for Lua.. AFAIK PHP has an automatic encode that scapes all characters, but there is none in Lua.. thanks.
Upvotes: 0
Views: 409
Reputation: 62831
Don't use backticks
, use apostrophes:
UPDATE stats
SET achievements = '[ { "Filthy Rich": "10\/12\/14", "I keep on rollin''": "10\/12\/14" } ]'
WHERE account = 'Feche'
Backticks are used to identify tables and columns, hence the unknown column error.
Also, you will need to escape any single quotes with double single quotes instead.
Upvotes: 1