=KoG=Rouche Posted August 31, 2014 Share Posted August 31, 2014 (edited) Hi all, i got this problem when i try to create the entry in my DB. DbExec failed; (1048) column "bMonth" could not be null. In the code bellow u can see that i initialize "bMonth" to 0 ...so what's wrong ? :-/ -- INSERT TO (Add an entity in player table) local bDay,bMonth,bYear,level,VIP,achievementPoints,token,tokenBought = 0 local mail,welcomeText = "none" dbExec(connect,"INSERT INTO Player (account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) VALUES (?,?,?,?,?,?,?,?,?,?,?)",account,mail,bDay,bMonth,bYear,level,VIP,welcomeText,achivementPoints,token,tokenbought) outputDebugString("An entity in Player Table has been Created - OK") Thanks for your help. =KoG=Rouche Edited September 2, 2014 by Guest Link to comment
myonlake Posted August 31, 2014 Share Posted August 31, 2014 You must define each an every variable with their own value, unfortunately, so if you check up that code on your Lua virtual engine, you can actually see that it returns nil on all the variables except the first one. Link to comment
=KoG=Rouche Posted September 1, 2014 Author Share Posted September 1, 2014 Thanks it works now I've a new problem. I try to check if the user is already registered in the database but it seems that it's not working. When i try to outputDebugString the "compare" var it says "Excpected String at argument 1, got nil" So i think i don't use the dbPoll very well. Can someone help me ? -- Check if a user already exsit in database function checkIfUserExist() outputDebugString("Check if in checkIfUserExist Function - OK") local query = dbQuery(connect, "SELECT account FROM Player WHERE account = ?", account) local result = dbPoll(query, -1) local compare = result[1] outputDebugString(compare) if compare then local compAccount = compare.account outputDebugString(compAccount) if compAccount == account then return 1 -- User already exist in DB else return 0 -- User doesn't exist in DB end else return 0 end end Thanks. Link to comment
Anubhav Posted September 1, 2014 Share Posted September 1, 2014 -- Check if a user already exsit in database function checkIfUserExist() outputDebugString("Check if in checkIfUserExist Function - OK") local query = dbQuery(connect, "SELECT account FROM Player WHERE account = ?", account) local result = dbPoll(query, -1) local compare = result[1] if compare then outputDebugString(compare) local compAccount = compare.account outputDebugString(compAccount) if compAccount == account then return 1 -- User already exist in DB else return 0 -- User doesn't exist in DB end else return 0 end end Link to comment
=KoG=Rouche Posted September 1, 2014 Author Share Posted September 1, 2014 Why did u just copied the code ? Without edit 0.o Link to comment
Anubhav Posted September 1, 2014 Share Posted September 1, 2014 Did you even see the difference dafuq.. I din't copied the code. Link to comment
=KoG=Rouche Posted September 2, 2014 Author Share Posted September 2, 2014 Here is what i did to made it work. I can't see any difference except a "OutputDebugScript" moved 0.o Maybe its better to let a little commentary when u change something. -- Check if a user already exsit in database function checkIfUserExist() outputDebugString("Check if in checkIfUserExist Function - OK") local theAccount = getPlayerAccount(source) local account = getAccountName(theAccount) local query = dbQuery(connect, "SELECT account FROM Player WHERE account = ?", account) local result = dbPoll(query, -1) local compare = result[1] if compare then local compAccount = compare.account outputDebugString(compAccount) if compAccount == account then return 1 -- User already exist in DB else return 0 -- User doesn't exist in DB end else return 0 end end Link to comment
Anubhav Posted September 2, 2014 Share Posted September 2, 2014 Here is what i did to made it work.I can't see any difference except a "OutputDebugScript" moved 0.o Maybe its better to let a little commentary when u change something. -- Check if a user already exsit in database function checkIfUserExist() outputDebugString("Check if in checkIfUserExist Function - OK") local theAccount = getPlayerAccount(source) local account = getAccountName(theAccount) local query = dbQuery(connect, "SELECT account FROM Player WHERE account = ?", account) local result = dbPoll(query, -1) local compare = result[1] if compare then local compAccount = compare.account outputDebugString(compAccount) if compAccount == account then return 1 -- User already exist in DB else return 0 -- User doesn't exist in DB end else return 0 end end Did it output something?? 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