WASSIm. Posted October 22, 2013 Share Posted October 22, 2013 hi guys i have problem with sql its show me this. plis help 5: dbExec failed; (1) duplicate column name: turfid addEventHandler ( "onResourceStart", resourceRoot, function ( ) connection = dbConnect( "sqlite", "turfs.db" ) if ( connection )then dbExec ( connection, "CREATE TABLE IF NOT EXISTS turfs (turfID INTEGER PRIMARY KEY NOT NULL, turfid TEXT, turfowner INT, x INT, y INT, sizex INT, sizey INT, r INT, g INT, b INT)" ) outputDebugString ( "Successfully connected to turfs.db" ) else outputDebugString ( "Failed to connect to turfs.db", 3 ) end end ) Link to comment
Compa Posted October 22, 2013 Share Posted October 22, 2013 You have 2 times the same column like the error said. You have turfID (integer) and turfid (text). You have to change the name of one of those 2. May i ask why you want to store a integer version and a text version of the id? The integer version is enough. Link to comment
WASSIm. Posted October 22, 2013 Author Share Posted October 22, 2013 i have other problem. he is show me this 84: dbExec failed; (1) near "turfColorG": syntax error function setTurfColor ( turfID, r, g, b ) if ( not doesTurfExist ( turfID ) ) then return false, "This turf does not exists." end local handler = connection if ( not handler ) then return false, "Couldn't connect to SQLite database." end return dbExec( handler, "UPDATE turfs SET turfColorR = '".. tostring ( r ) .."' turfColorG = '".. tostring ( g ) .."' turfColorB = '".. tostring ( b ) .."' WHERE turf = '" .. tostring ( turfID ) .."'" ) end Link to comment
Compa Posted October 22, 2013 Share Posted October 22, 2013 function setTurfColor ( turfID, r, g, b ) if ( not doesTurfExist ( turfID ) ) then return false, "This turf does not exists." end local handler = connection if ( not handler ) then return false, "Couldn't connect to SQLite database." end return dbExec( handler, "UPDATE turfs SET turfColorR = '".. tostring ( r ) .."', turfColorG = '".. tostring ( g ) .."', turfColorB = '".. tostring ( b ) .."' WHERE turf = '" .. tostring ( turfID ) .."'" ) end Link to comment
WASSIm. Posted October 22, 2013 Author Share Posted October 22, 2013 thank you its working. can you help me on this. sry i am new to SQL :104: Bad argument @ 'dbExec' [Expected db-connection at argument 1] function setPlayerZombieKill(thePlayer, theZKill) local handler = connection if (isElement(thePlayer) and getElementType(thePlayer) == "player") then account = getPlayerAccount(thePlayer) else account = thePlayer end if (not account or isGuestAccount(account)) then return false end local accountName = getAccountName(account) if dbExec( handler, "UPDATE zkills SET zkill = '" .. tonumber(theZKill) .. "' WHERE accountName = '" .. tostring(accountName) .."'" ) then return true else return false end end Link to comment
Castillo Posted October 22, 2013 Share Posted October 22, 2013 Is 'connection' defined in the same script? Link to comment
WASSIm. Posted October 22, 2013 Author Share Posted October 22, 2013 Is 'connection' defined in the same script? yes Link to comment
Compa Posted October 22, 2013 Share Posted October 22, 2013 Is 'connection' defined in the same script? yes Post your connection with your password hidden. Link to comment
WASSIm. Posted October 22, 2013 Author Share Posted October 22, 2013 addEventHandler ( "onResourceStart", resourceRoot, function ( ) connection = dbConnect( "sqlite", "zkills.db" ) exports [ "scoreboard" ]:addScoreboardColumn( "Zombie kills", root, 90, "Z kills", 6 ) if ( connection )then dbExec ( connection, "CREATE TABLE IF NOT EXISTS zkills (zkillID INTEGER PRIMARY KEY NOT NULL, accountName TEXT, zkill INT)" ) outputDebugString ( "Successfully connected to zkills.db" ) else outputDebugString ( "Failed to connect to zkills.db", 3 ) end end ) Link to comment
.:HyPeX:. Posted October 23, 2013 Share Posted October 23, 2013 function setPlayerZombieKill(thePlayer, theZKill) local handler = connection if (isElement(thePlayer) and getElementType(thePlayer) == "player") then account = getPlayerAccount(thePlayer) else account = thePlayer end if (not account or isGuestAccount(account)) then return false end local accountName = getAccountName(account) if dbExec( handler, "UPDATE zkills SET zkill = '" .. tonumber(theZKill) .. "' WHERE accountName = '" .. tostring(accountName) .."'" ) then return true else return false end end why you used 'handler'? it should be 'connection' as defined... function setPlayerZombieKill(thePlayer, theZKill) if (isElement(thePlayer) and getElementType(thePlayer) == "player") then account = getPlayerAccount(thePlayer) else account = thePlayer end if (not account or isGuestAccount(account)) then return false end local accountName = getAccountName(account) if dbExec( connection, "UPDATE zkills SET zkill = '" .. tonumber(theZKill) .. "' WHERE accountName = '" .. tostring(accountName) .."'" ) then return true else return false end end Link to comment
Castillo Posted October 23, 2013 Share Posted October 23, 2013 Same problem ( Expected db-connection )? Link to comment
Castillo Posted October 23, 2013 Share Posted October 23, 2013 Can you post or send me on PM the whole script? 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