xXMADEXx Posted May 19, 2013 Share Posted May 19, 2013 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
Castillo Posted May 19, 2013 Share Posted May 19, 2013 That's because: Returns true unless the connection is incorrect, in which case it returns false. You must use: dbQuery Link to comment
xXMADEXx Posted May 19, 2013 Author Share Posted May 19, 2013 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
Castillo Posted May 19, 2013 Share Posted May 19, 2013 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
xXMADEXx Posted May 19, 2013 Author Share Posted May 19, 2013 Thank you very much , it works. 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