Raised This Month: $32 Target: $400
 8% 

SQLite not updating tables


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Toxic360
New Member
Join Date: Aug 2012
Old 02-19-2020 , 15:40   SQLite not updating tables
Reply With Quote #1

Howdy y'all.

Pretty simple problem, really. Yesterday these same lines were working fine and updating. Last night I upgraded my server from ubuntu 18.04 to ubuntu 19.(whatever). As of today, the UPDATE function no longer works in this plugin.

PHP Code:
Format(buff,sizeof(buff),"UPDATE players SET character='%s' WHERE steamid = '%s'","Bill",menuids)
SQL_TQuery(db,SQLErrorCheckCallback,buff)

public 
SQLErrorCheckCallback(Handle:ownerHandle:hndl, const String:error[], client)
{
    if(!
StrEqual(""error))
    {
        
PrintToServer("SQL Error: %s"error);
    }

While this doesn't work, I know for a fact that these lines do:

PHP Code:

public InitializeDB()
{
    new 
String:Query1[255];
    new 
String:Query2[255];
    new 
String:Query3[255];
    
Format(Query1sizeof(Query1), "CREATE TABLE IF NOT EXISTS players (steamid TEXT UNIQUE, name TEXT, character TEXT, ellis INT);");
    
Format(Query2sizeof(Query2), "CREATE TABLE IF NOT EXISTS loadout (steamid TEXT UNIQUE, primaryweapon TEXT, secondaryweapon TEXT, throwable TEXT, health TEXT, boost TEXT, laser TEXT, FOREIGN KEY(steamID) REFERENCES players(steamID) ON UPDATE SET DEFAULT, PRIMARY KEY(steamID));");
    
Format(Query3sizeof(Query3), "CREATE TABLE IF NOT EXISTS infected (steamid TEXT UNIQUE, infected1 TEXT, infected2 TEXT, infected3 TEXT, FOREIGN KEY(steamID) REFERENCES players(steamID) ON UPDATE SET DEFAULT, PRIMARY KEY(steamID));");
    new 
String:error[255];
    
//yes I know this next line is outdated but it works
db SQL_ConnectEx(SQL_GetDriver("sqlite"), """""""sourcemod-local"errorsizeof(error), true0);
    if(
db == INVALID_HANDLE)
    {
        
SetFailState(error);
    }
    
SQL_LockDatabase(db);
    
SQL_FastQuery(db,Query1);
    
SQL_FastQuery(db,Query2);
    
SQL_FastQuery(db,Query3);
    
SQL_UnlockDatabase(db);
}

public 
initialAddToDatabase(client)
{
    new 
String:name[40];
    new 
String:sanitizedName[40]
    
GetClientName(clientnamesizeof(name));
    
SQL_EscapeString(db,name,sanitizedName,sizeof(name))
    
Format(buffsizeof(buff), "INSERT INTO players VALUES ('%s','%s','%s','%i')",steamId,sanitizedName,"bill",1);
    
SQL_TQuery(dbSQLErrorCheckCallbackbuff);
    
//adding default values to the loadout table
    
Format(buffsizeof(buff), "INSERT INTO loadout VALUES ('%s','%s','%s','%s','%s','%s','%s')",steamId,"rifle_ak47","katana","vomitjar","first_aid_kit","adrenaline","on");
    
SQL_TQuery(dbSQLErrorCheckCallbackbuff);
    
getEquipment(client)
    
//adding default values to the infected table
    
Format(buffsizeof(buff), "INSERT INTO infected VALUES ('%s','%i','%i','%i')",steamId,1,2,3);
    
SQL_TQuery(dbSQLErrorCheckCallbackbuff);

What did I do wrong? Is there any package I need to reinstall after upgrading?

EDIT:

I'm a dumbass. I put a query inside of OnPlayerRunCmd. Couldn't write to anything. fixed it

Last edited by Toxic360; 02-24-2020 at 16:42. Reason: Fixed it
Toxic360 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode