You generally don't want to query 3 times if you are querying from the same table. What could you do instead is select multiple columns in a single query. It is also good practice to escape any input you take from the user to prevent SQL injection.
The main problem you are facing right now is that you are not retrieving the column data for the query. QuerySQL doesn't return just the result but an object which contains information about the query. Ideally, something like this would be a half-decent approach:
The main problem you are facing right now is that you are not retrieving the column data for the query. QuerySQL doesn't return just the result but an object which contains information about the query. Ideally, something like this would be a half-decent approach:
Code Select
local accDetails = QuerySQL(db, format("SELECT IP, UID, UID2 FROM Accounts WHERE Name = '%s', escapeSQLString(plr)));
if (accDetails == null) // handle invalid nickname
else {
QuerySQL(db, format("INSERT INTO TempBans (Name, UID, UID2, IP, Time, ExpireTime, TimeExpireRatio, Admin, Reason) VALUES ('%s', '%s', '%s', '%s', %i, %i, %s, %s, %s)", escapeSQLString(plr), GetSQLColumnData(accDetails, 1), GetSQLColumnData(accDetails, 2), GetSQLColumnData(accDetails, 0), time(), calc, expire, player.Name, escapeSQLString(reason)));
}
