local tableSetup = [[CREATE TABLE IF NOT EXISTS UserTable (ID INTEGER PRIMARY KEY, NameOfUser);]]
local ResultTwo = db:exec(tableSetup)
if Result == 1 then
print(“Error”, tableSetup)
end
--------------------------------------------------------------------------------------------------------------||
function scene:createScene( event )
local screenGroup = self.view
– Background
local AddUserBox = display.newImage(“AddUserBox.png”);
screenGroup:insert(AddUserBox)
--------------------------------------------------------------------------------------------------------------||
– TextBox
local function onUserName(event)
if (event.phase == “began”) then
elseif (event.phase == “editing”) then
if string.len(event.target.text) > 0 then
event.target.text = string.sub(event.target.text, 5, 10)
end
elseif (event.phase == “submitted”) then
native.setKeyboardFocus = nil;
end
end
UserName = native.newTextField(90, 370, 420, 80)
UserName.font = native.newFont(native.systemFont, 50)
UserName.inputType = “text”
UserName.text = “Jonathan”
UserName:setTextColor(255, 0, 255)
UserName.align = “Center”
screenGroup:insert(UserName)
function StoreValues()
local tableFill = [[INSERT INTO UserTable VALUES (NULL, “]]…UserName.text…[[”, 30, “unknown”)]]
local Result = db:exec(tableFill)
if Result == 1 then
print(“Error”, tableFill)
end
end
There are multiple errors in your code.
-
In create table NameOfUser has no type
-
In insert statement you have 4 values and in the create you only specified 2.
-
You did not set up an event listener for newTextField
…
Tackle one problem at a time. Look at the console for errors and address them as they show up.
Posting code and saying help does not give us much to go on. Post errors you get.
there are no errors showing up Sir. thank you!
Well what is the problem then? Set up an event listener for your newTextField http://docs.coronalabs.com/api/event/userInput/index.html
and on submitted phase call your StoreValues function. You are currently not calling it anywhere.
Also when checking sql errors test result ~= 0. 1 is not the only error you can get.
http://luasqlite.luaforge.net/lsqlite3.html#numerical%20error%20and%20result%20codes
There are multiple errors in your code.
-
In create table NameOfUser has no type
-
In insert statement you have 4 values and in the create you only specified 2.
-
You did not set up an event listener for newTextField
…
Tackle one problem at a time. Look at the console for errors and address them as they show up.
Posting code and saying help does not give us much to go on. Post errors you get.
there are no errors showing up Sir. thank you!
Well what is the problem then? Set up an event listener for your newTextField http://docs.coronalabs.com/api/event/userInput/index.html
and on submitted phase call your StoreValues function. You are currently not calling it anywhere.
Also when checking sql errors test result ~= 0. 1 is not the only error you can get.
http://luasqlite.luaforge.net/lsqlite3.html#numerical%20error%20and%20result%20codes