Jump to content

Checking MySQL Database


Recommended Posts

Hi guys, im trying to check my database, to see if the account exists. For some reason, it just keeps returning true, and i don't really know how to make it check if the account exists, and if it does then return true, but if it dosn't then return false...

Please help.

addCommandHandler("c", 
    function ( player, command, accountName ) 
        local v = dbExec ( dbc, "SELECT name FROM Accounts WHERE name=?", accountName ) 
        outputChatBox ( tostring ( v ) ) 
    end 
) 

Link to comment

Okey, so i updated the script, but its returning table data...

addCommandHandler ( "c", 
    function ( player, command, accnt ) 
        local new = dbQuery ( dbc, "SELECT name FROM Accounts WHERE name=?", accnt ) 
        outputChatBox ( tostring ( dbPoll ( new, -1 ) ) ) 
    end 
) 

Link to comment
addCommandHandler ( "c", 
    function ( player, command, accnt ) 
        local new = dbQuery ( dbc, "SELECT name FROM Accounts WHERE name=?", accnt ) 
        local result = dbPoll ( new, - 1 ) 
        if ( type ( result ) == "table" and #result == 0 or not result ) then 
            outputChatBox ( "Not in table" ) 
        else 
            outputChatBox ( "In table" ) 
        end 
    end 
) 

Link to comment

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...