undefined Posted February 1, 2015 Share Posted February 1, 2015 (edited) Hi guys. Im work on my save system. But I have a problem. I get this error: ERROR: mas\DB\hud_option.lua:29: Database query failed: no such table: hud_option ERROR: mas\DB\hud_option.lua:29: attempt to index field '?' (a nil value) Here is my DB:(Empty) And here is my code: Code Removed Help pls... Edited February 6, 2015 by Guest Link to comment
WASSIm. Posted February 1, 2015 Share Posted February 1, 2015 i don't see tablr called hud_option Link to comment
undefined Posted February 1, 2015 Author Share Posted February 1, 2015 Is not it? dbQuery(connectDB, "CREATE TABLE IF NOT EXISTS hud_option (hudColor STRING, hudOption STRING") Link to comment
WASSIm. Posted February 1, 2015 Share Posted February 1, 2015 i mean database server not database on custom file bcs you'r use executeSQLQuery if you see it in line 31 Link to comment
undefined Posted February 1, 2015 Author Share Posted February 1, 2015 (edited) Here is my new code: Code Removed And Error: ERROR: mas\DB\hud_option.lua:43: attempt to index a userdata value Edited February 6, 2015 by Guest Link to comment
WASSIm. Posted February 1, 2015 Share Posted February 1, 2015 you forget to use dbPoll Link to comment
undefined Posted February 2, 2015 Author Share Posted February 2, 2015 What is this? I read this on wiki but I don't understand. Link to comment
TAPL Posted February 2, 2015 Share Posted February 2, 2015 It's return the result of the query. Also for update and insert use dbExec because there's no result will be returned. Link to comment
undefined Posted February 2, 2015 Author Share Posted February 2, 2015 local query = dbQuery(connectDB, "SELECT hudColor FROM hud_option WHERE account_name=?", tostring(account_name))[1].hudColor -- Line 42 local result = dbPoll(query, -1) if result then return fromJSON(query) end I'm make this but it's not work! ERROR: mas\DB\hud_option.lua:42: attempt to index a userdata value Link to comment
TAPL Posted February 2, 2015 Share Posted February 2, 2015 You should return the result not the query. And the close bracket at line 1 is missing. Link to comment
undefined Posted February 2, 2015 Author Share Posted February 2, 2015 local query = dbQuery(connectDB, "SELECT hudColor FROM hud_option WHERE account_name=?", tostring(account_name)) local result = dbPoll(query, -1) if result then return result end And the close bracket at line 1 is missing. Where? I can't see. Can you show me? Link to comment
TAPL Posted February 2, 2015 Share Posted February 2, 2015 local query = dbQuery(connectDB, "SELECT hudColor FROM hud_option WHERE account_name=?", tostring(account_name)) local result = dbPoll(query, -1) if result then return result end And the close bracket at line 1 is missing. Where? I can't see. Can you show me? Nothing in this code, have you tried it? Link to comment
undefined Posted February 2, 2015 Author Share Posted February 2, 2015 (edited) Yes, I tried it. It's not give error or warning. And it's not work. The result table is empyt. Here is my new all code: Code Removed Edited February 6, 2015 by Guest Link to comment
WASSIm. Posted February 2, 2015 Share Posted February 2, 2015 dbPoll: for get result from dbQuery dbQuery: for get data from database dbExec: for edit database Link to comment
Noki Posted February 3, 2015 Share Posted February 3, 2015 Pseudo code: Query from the database Poll the query If query poll returned a table Do what you want Link to comment
WASSIm. Posted February 3, 2015 Share Posted February 3, 2015 SO... look at your code again Link to comment
undefined Posted February 3, 2015 Author Share Posted February 3, 2015 I'm new on SQLite. I can't see my mistake Please show me my mistake Link to comment
WASSIm. Posted February 3, 2015 Share Posted February 3, 2015 (edited) try this REMOVE Edited February 6, 2015 by Guest Link to comment
undefined Posted February 3, 2015 Author Share Posted February 3, 2015 (edited) @Wassim I already solved this problem. But thank you nevertheless. Code Removed OK. I understand now . Now, return is not work. Look at the line 11 It must say; [ [ true, true, true, true, false, 255, 190, true, true ] ] But it say; [ [ { "hudOption": false } ] ] Where is the problem? Edit: return dbPoll(dbQuery(connectDB, "SELECT hudOption FROM hud_option WHERE account_name=?", tostring(account_name)), -1)[1].hudOption-- Line 63 outputChatBox said: [ false ] Edited February 6, 2015 by Guest Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now