new function params error

I did something wrong in this code?

 module(..., package.seeall);  
  
 function new ()  
 math.randomseed( os.time() )  
 local Scene = display.newGroup()  
 local bg1 = display.newGroup ()  
  
 require "sqlite3"  
  
  
 local timeDelay = 1000 --Cat de repede se numara . 1/1 secunda  
 local runMode = true  
 local bg = display.newImage("bg.png",0,0)  
 bg1:insert(bg)  
  
 local scoreText = display.newText("Score:", 7 , 40 , native.systemFont,50 )  
 scoreText:setTextColor(255,255,255)  
 local scorenr = 0  
 local scoreNumber = display.newText ("0",190,40,native.systemFont,50)  
 bg1:insert(scoreText)  
 bg1:insert(scoreNumber)  
 function score ()  
 scorenr = scorenr+10  
 scoreNumber .text = scorenr  
 end  
  
  
  
 local lives = 5  
 local lifeIcons={}  
 local maxLives = 5  
 local i  
  
 local function health(currentLives)  
 for i = 1, currentLives do  
 if lifeIcons[i] then  
 lifeIcons[i].isVisible = true  
 else  
 lifeIcons[i] = display.newImage("heart.png")  
 lifeIcons[i].x =560 + (lifeIcons[i].contentWidth \* (i - 1))  
 lifeIcons[i].y = 30 -- start at 10,10  
 bg1:insert(lifeIcons[i])  
 end  
 end  
 for i = currentLives + 1, #lifeIcons do  
 if maxLives \> 0 then  
 lifeIcons[i].isVisible = false  
 end  
  
 end  
 end  
 health(maxLives)  
 local utilitarex = display.contentWidth/1.5  
 local utilitarey = display.contentHeight/18  
  
 local timerr = display.newImage("timer1.png")  
 bg1:insert(timerr)  
 timerr.x = utilitarex  
 timerr.y = utilitarey  
  
 local fiftyfifty = display.newImage("fiftyfifty.png")  
 bg1:insert(fiftyfifty)  
 fiftyfifty.x =utilitarex+90  
 fiftyfifty.y = utilitarey  
  
 local nextquestion = display.newImage("sageata2.png")  
 bg1:insert(nextquestion)  
 nextquestion.x = utilitarex+180  
 nextquestion.y = utilitarey  
 local correct = display.newImage("button\_ok.png")  
 bg1:insert(correct)  
 correct.x = display.contentWidth/2  
 correct.y = display.contentHeight/1.4  
  
 local gresit = display.newImage("button\_wrong.png")  
 bg1:insert(gresit)  
 gresit.x = display.contentWidth/2  
 gresit.y = display.contentHeight/1.4  
 local buton1 = display.newImage("buton.png")  
 bg1:insert(buton1)  
  
 buton1.xReference = 432/2  
 buton1.yReference = 77/2  
  
 buton1.x = display.contentWidth /(4.78/2)  
 buton1.y = display.contentHeight - display.contentHeight/3  
  
 local buton2 = display.newImage("buton.png")  
 buton2.xReference = 432/2  
 buton2.yReference = 77/2  
 bg1:insert(buton2)  
  
 buton2.x = display.contentWidth /(4.78/2)  
 buton2.y = display.contentHeight - display.contentHeight/8  
  
 local buton3 = display.newImage("buton.png")  
 buton3.xReference = 432/2  
 buton3.yReference = 77/2  
 buton3.x = display.contentWidth -display.contentWidth/12  
 buton3.y = display.contentHeight - display.contentHeight/3  
 bg1:insert(buton3)  
  
 local buton4 = display.newImage("buton.png")  
 buton4.xReference = 432/2  
 buton4.yReference = 77/2  
 buton4.x = display.contentWidth -display.contentWidth/12  
 buton4.y = display.contentHeight - display.contentHeight/8  
 bg1:insert(buton4)  
  
 local path = system.pathForFile ( "SQL.db", system.DocumentsDirectory)  
 local db = sqlite3.open(path)  
  
 local irgroup = display.newGroup()  
 local question =display.newText("",10,10,system.nativeFont,36)  
 question:setReferencePoint(display.CenterReferencePoint)  
 question.x = display.contentWidth/2  
 question.y = display.contentHeight/3  
 bg1:insert(question)  
  
 local raspuns1 = display.newText("",display.contentWidth /(4.78/2),500,system.nativeFont,36)  
 raspuns1:setReferencePoint(display.CenterReferencePoint)  
 raspuns1.x = display.contentWidth /(4.78/2) -buton1.width/2  
 raspuns1.y= display.contentHeight-display.contentHeight/5.5  
 bg1:insert(raspuns1)  
 local raspuns2 = display.newText("",display.contentWidth /(4.78/2),10,system.nativeFont,36)  
 raspuns2:setReferencePoint(display.CenterReferencePoint)  
 raspuns2.x = display.contentWidth /(4.78/2) -buton1.width/2  
 raspuns2.y= display.contentHeight-display.contentHeight/2.6  
 bg1:insert(raspuns2)  
  
 local raspuns3= display.newText("", display.contentWidth-display.contentWidth /(4.78/2),10,system.nativeFont,36)  
 raspuns3:setReferencePoint(display.CenterReferencePoint)  
 raspuns3.x = display.contentWidth/1.34  
 raspuns3.y = display.contentHeight-display.contentHeight/5.5  
 bg1:insert(raspuns3)  
  
 local raspuns4= display.newText("",10,10,system.nativeFont,36)  
 raspuns4:setReferencePoint(display.CenterReferencePoint)  
 raspuns4.x = display.contentWidth/1.34  
 raspuns4.y = display.contentHeight-display.contentHeight/2.6  
 bg1:insert(raspuns4)  
  
 irgroup : insert(question)  
 irgroup : insert(raspuns1)  
 irgroup : insert(raspuns2)  
 irgroup : insert(raspuns3)  
 irgroup : insert(raspuns4)  
  
 local intrebare  
 local raspunscorect  
 local raspunsgresit={}  
 local random  
  
 local function questionsanswers()  
 if maxLives \> 0 then  
 correct.isVisible = false  
 gresit.isVisible = false  
 random = math.random(57)  
 print(random)  
 for row in db:nrows("SELECT \* FROM intrebari where id ="..random) do  
 intrebare = row.Question  
 raspunscorect = row.Correct\_Answer  
 raspunsgresit[0]= row.Wrong\_Answer1  
 raspunsgresit[1]=row.Wrong\_Answer2  
 raspunsgresit[2]=row.Wrong\_Answer3  
 raspunsgresit[3]=row.Wrong\_Answer4  
 break  
 end  
 print(raspunscorect)  
  
 question.text = intrebare  
 bg1:insert(question)  
  
 raspuns2.text = raspunsgresit[0] --ATENTIE LA ORDINE!!! MI-A FOST LENE   
 bg1:insert(raspuns2)  
 raspuns1.text = raspunsgresit[1]  
 bg1:insert(raspuns1)  
 raspuns3.text = raspunsgresit[2]  
 bg1:insert(raspuns3)  
 raspuns4.text = raspunsgresit[3]  
 bg1:insert(raspuns4)  
 random = math.random(1,54)  
  
 end  
 end  
  
 if maxLives \> 0 then  
 questionsanswers()  
 end  
  
  
 local t = display.newText( "20", 115, 105, "DS-Digital", 50 )  
   
 t:setTextColor( 0, 0, 0 )  
 local count = 20  
 function t:timer( event )  
  
  
 count = 20-event.count  
 self.text = count  
  
  
 if count == 0 then  
 timer.cancel( event.source )  
 t.text = "20"  
  
 maxLives = maxLives - 1  
  
 health(maxLives)  
 questionsanswers()  
  
 timerID = timer.performWithDelay( timeDelay, self,-1 )  
  
 end  
  
 end  
 bg1:insert(t)  
if maxLives \> 0 then  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
  
end  
  
 local function checkcorrectanswer1(event)  
 if(raspunsgresit[0]==raspunscorect) then  
 correct.isVisible = true  
 print("Corect")  
 timer.performWithDelay ( 1000, questionsanswers )  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 t.text = "20"  
 score()  
 else  
 gresit.isVisible = true  
  
 maxLives = maxLives - 1  
 health(maxLives)  
 timer.performWithDelay ( 1000, questionsanswers )  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 t.text = "20"  
 timer.performWithDelay ( 1000, questionsanswers )  
 end  
 end  
  
 local function checkcorrectanswer2(event)  
 if(raspunsgresit[1]==raspunscorect) then  
 correct.isVisible = true  
 print("Corect")  
 timer.performWithDelay ( 1000, questionsanswers )  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 t.text = "20"  
 score()  
 else  
 gresit.isVisible = true  
 maxLives = maxLives - 1  
 health(maxLives)  
 timer.performWithDelay ( 1000, questionsanswers )  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 t.text = "20"  
 timer.performWithDelay ( 1000, questionsanswers )  
 end  
 end  
  
 local function checkcorrectanswer3(event)  
 if(raspunsgresit[3]==raspunscorect) then  
 correct.isVisible = true  
 print("Corect")  
  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 t.text = "20"  
 timer.performWithDelay ( 1000, questionsanswers )  
 score()  
 else  
 gresit.isVisible = true  
 maxLives = maxLives - 1  
 health(maxLives)  
 timer.performWithDelay ( 1000, questionsanswers )  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 t.text = "20"  
 timer.performWithDelay ( 1000, questionsanswers )  
 end  
 end  
  
 local function checkcorrectanswer4(event)  
 if(raspunsgresit[2]==raspunscorect) then  
 correct.isVisible = true  
 print("Corect")  
 timer.performWithDelay ( 1000, questionsanswers )  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 t.text = "20"  
 score()  
 else  
 gresit.isVisible = true  
 maxLives = maxLives - 1  
 health(maxLives)  
 timer.performWithDelay ( 1000, questionsanswers )  
  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 t.text = "20"  
 timer.performWithDelay ( 1000, questionsanswers )  
  
 end  
 end  
  
 --Cele 3 utilitare  
  
 local function deletequestions(event)  
  
 questionsanswers()  
 t.text = "20"  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 nextquestion.isVisible = false  
 nextquestion:removeEventListener ( "tap", deletequestions )  
 end  
 local function addtimer(event)  
 t.text = "20"  
 timer.cancel(timerID)  
 timerID = timer.performWithDelay( timeDelay, t,-1 )  
 timerr.isVisible = false  
 timerr:removeEventListener ( "tap", timerr )  
 end  
 local function r2answers(event)  
  
 if(raspunsgresit[0]~=raspunscorect and raspunsgresit[1]~=raspunscorect) then  
 raspuns2.text = ""  
 raspuns1.text= ""  
 elseif(raspunsgresit[0]~=raspunscorect and raspunsgresit[2]~=raspunscorect) then  
 raspuns2.text = ""  
 raspuns3.text= ""  
 elseif(raspunsgresit[0]~=raspunscorect and raspunsgresit[3]~=raspunscorect) then  
 raspuns2.text = ""  
 raspuns4.text= ""  
  
 elseif(raspunsgresit[1]~=raspunscorect and raspunsgresit[2]~=raspunscorect) then  
 raspuns3.text=""  
 raspuns1.text=""  
  
 elseif(raspunsgresit[1]~=raspunscorect and raspunsgresit[3]~=raspunscorect) then  
 raspuns1.text=""  
 raspuns4.text=""  
  
 elseif(raspunsgresit[2]~=raspunscorect and raspunsgresit[3]~=raspunscorect) then  
 raspuns3.text=""  
 raspuns2.text=""  
 else  
 raspuns1.text = ""  
 raspuns4.text= ""  
 end  
 fiftyfifty.isVisible = false  
  
 end  
  
 local function clean()  
 timer.cancel(timerID)  
 end  
  
 local function hasHealth()  
 if maxLives == 0 then   
 local parameters = {finalscore=scorenr}  
  
 director:changeScene(parameters,"endgame")  
 end  
 end  
  
 --EventListeners  
 fiftyfifty:addEventListener("tap",r2answers)  
 nextquestion:addEventListener("tap", deletequestions)  
 timerr:addEventListener("tap",addtimer)  
 buton1:addEventListener("tap",checkcorrectanswer1)  
 buton2:addEventListener("tap",checkcorrectanswer2)  
 buton3:addEventListener("tap",checkcorrectanswer3)  
 buton4:addEventListener("tap",checkcorrectanswer4)  
 Runtime:addEventListener("enterFrame", hasHealth)  
  
  
 Scene:insert(bg1)  
 return Scene  
end  
  

The images names are correct. [import]uid: 178587 topic_id: 32196 reply_id: 332196[/import]

It would be uber helpful if we knew what was wrong with it? What errors are you seeing in the console? How is it behaving badly? [import]uid: 19626 topic_id: 32196 reply_id: 128190[/import]

Everything works great in the simulator but on device I get this error.
https://mail-attachment.googleusercontent.com/attachment/u/0/?ui=2&ik=c2966103bd&view=att&th=13a75cc6acb99928&attid=0.1&disp=inline&realattid=1416202611389890560-1&safe=1&zw&saduie=AG9B_P_uUo_x-se0Z1KBfEY8WcEO&sadet=1350939014576&sads=Ar8KHk0Een2sFM1qzkbDbH4v7Rc&sadssc=1
Failed to execute function (params).
The credits and menu scenes are working perfectly.
That error appears when I want to play the game. [import]uid: 178587 topic_id: 32196 reply_id: 128201[/import]

Well the #1 most common problem of “works in the simulator, not on the device” is a filename case issue.

Make sure your file names match exactly. Game.lua is game.lua are the same to the simulator but not the device. Don’t limit your check to the lua files, but also check all of your image names too.
[import]uid: 19626 topic_id: 32196 reply_id: 128207[/import]

The file names are correctly. I verified 3 times.
I think the database could be the problem.
Before I compile the app, I put the database in the Documents’ Folder in Sandbox. Is that ok?
[import]uid: 178587 topic_id: 32196 reply_id: 128254[/import]

It would be uber helpful if we knew what was wrong with it? What errors are you seeing in the console? How is it behaving badly? [import]uid: 19626 topic_id: 32196 reply_id: 128190[/import]

Everything works great in the simulator but on device I get this error.
https://mail-attachment.googleusercontent.com/attachment/u/0/?ui=2&ik=c2966103bd&view=att&th=13a75cc6acb99928&attid=0.1&disp=inline&realattid=1416202611389890560-1&safe=1&zw&saduie=AG9B_P_uUo_x-se0Z1KBfEY8WcEO&sadet=1350939014576&sads=Ar8KHk0Een2sFM1qzkbDbH4v7Rc&sadssc=1
Failed to execute function (params).
The credits and menu scenes are working perfectly.
That error appears when I want to play the game. [import]uid: 178587 topic_id: 32196 reply_id: 128201[/import]

Well the #1 most common problem of “works in the simulator, not on the device” is a filename case issue.

Make sure your file names match exactly. Game.lua is game.lua are the same to the simulator but not the device. Don’t limit your check to the lua files, but also check all of your image names too.
[import]uid: 19626 topic_id: 32196 reply_id: 128207[/import]

The file names are correctly. I verified 3 times.
I think the database could be the problem.
Before I compile the app, I put the database in the Documents’ Folder in Sandbox. Is that ok?
[import]uid: 178587 topic_id: 32196 reply_id: 128254[/import]