0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

@Feche1320 -- I think you now have a different error. Looks like you have a single quote in your string. That needs to be escaped.
Indeed that was the problem, sorry for the stupid question, thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.