SpecT Posted October 24, 2015 Share Posted October 24, 2015 (edited) Hey guys! I'm having a problem with my first sql script/system. So it's a music system. It used to get the songs from XML but since XML isn't good for large data I decided to learn and make it with SQL. So yeah I successfully moved the data from the XML file to the SQL file and it's working good. The problem is on the loading part - I want to make it in a table and for some reason it gives me an error "attempt to index global "t" (a nil value). Here is wrong code: if result then for _, row in ipairs ( result ) do local name, length, played = (row['songName']), row['length'], row['requested'] t[name] = {name,length,played} songData = t end end It loads normally when its like that : t = {name,length,played} but doesn't load when its like the above code. Thanks in advance! Edited October 25, 2015 by Guest Link to comment
TAPL Posted October 24, 2015 Share Posted October 24, 2015 What the purpose of line 5? You should define t as a table on top of the code: t = {} Link to comment
SpecT Posted October 24, 2015 Author Share Posted October 24, 2015 What the purpose of line 5?You should define t as a table on top of the code: t = {} Yeah lol I missed that. It used to cause some more errors but I fixed them so now it's working fine. Anyway thanks for the reply! 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