Jump to content

Problem SQL


WASSIm.

Recommended Posts

Posted

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 
) 

Omerta Roleplay

Posted

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.

Posted

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 

Omerta Roleplay

Posted
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 

Posted

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 

Omerta Roleplay

Posted

Is 'connection' defined in the same script?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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 
) 

Omerta Roleplay

Posted
  
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 

My ingame nick is ~HyPeX~

BF3 Gamemode Progress: ~30% - Currently working on AI & MapManager

gKhdyRJ.png

Posted

Same problem ( Expected db-connection )?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Can you post or send me on PM the whole script?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...