• SQL Insert issue
    3 replies, posted
Hello everyone! Using MySQLoo v9: MySQLoov9 Github The thing that I am trying to do is to first, check if the players steamid is in the table. If thats true then just load the players stuff. If not true create the player. But my problem is that when I am checking using the code under this text it returns false even if the player was logged before. ( The function "LoadPlayerSQL" is in the "PlayerInitialSpawn" hook ) function LoadPlayerSQL( ply ) local steamID = ply:SteamID() local q = sql.Query( "SELECT * FROM leeroys_table WHERE uuid = '" .. steamID .. "' AND level IS NOT NULL AND xp IS NOT NULL AND money IS NOT NULL" ) if( q ) then -- do some more sql stuff else CreatePlayerSQL( ply ) text( ply:Nick() .. " did not exist in the database. Creating...", 0 ) end end It could be the query in the if statement but I don't know. function CreatePlayerSQL( ply ) steamID = ply:SteamID() sql_insert_result = sql.Query( "INSERT INTO leeroys_table (uuid, money, level, xp) VALUES('" .. steamID .. "', 100, 1, 0" ) end Everytime I join/rejoin it keeps attempting to log my steamid but fails. I don't know why. This is how I create the table in the "Initialize" hook. if( sql.TableExists( leeroys_table ) then print("Table already exists!") else sql.Query("CREATE TABLE leeroys_table ( uuid varchar(255), money int, level int, xp int );") end Might be a simple solution or that maybe my mysql host is shit.
I don't think you need to verify if the values are nil in your query.
Isn't sql.* the provided SQLite functions and not MySqlOOs?
Could be it xD
Sorry, you need to Log In to post a reply to this thread.