Raised This Month: $18 Target: $400
 4% 

Solved Database messing with me again.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Location: Not your business.
Old 08-04-2018 , 19:27   Database messing with me again.
Reply With Quote #1

Wadup, getting this annoying ass error: Exception reported: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

Something has got to be wrong with this, since the tables are being created but client is never inserted into the database.
PHP Code:
void SQL_LoadClient(int iClient)
{
    
GetClientAuthId(iClientAuthId_Steam2g_sSteamid[iClient], sizeof(g_sSteamid[]));
    
    
char sQuery[256];
    
Format(sQuerysizeof(sQuery), "SELECT * FROM mugistats WHERE steam_id = \"%s\""g_sSteamid[iClient]);
    
    
g_hDatabase.Query(SQL_AuthorizationsQueryGetClientUserId(iClient));
}

public 
void SQL_Authorization(Database hDatabaseDBResultSet hResults, const char[] sErrorint iData)
{
    if (
hResults == null)
        
ThrowError(sError);
    
    
int iClient GetClientOfUserId(iData);
    
    if (
IsValidClient(iClient))
    {
        if (
hResults.RowCount != 0)
        {
            
hResults.FetchRow();
            
            
g_iExp[iClient] = hResults.FetchInt(2);
            
g_iKills[iClient] = hResults.FetchInt(3);
            
g_iDeaths[iClient] = hResults.FetchInt(4);
            
g_iHeadshots[iClient] = hResults.FetchInt(5);
            
g_iSuicides[iClient] = hResults.FetchInt(6);
            
g_iDamage[iClient] = hResults.FetchInt(7);
            
g_iKnifeKills[iClient] = hResults.FetchInt(8);
            
g_iNadeKills[iClient] = hResults.FetchInt(9);
            
g_iRoundsWon[iClient] = hResults.FetchInt(10);
            
g_iRoundsLost[iClient] = hResults.FetchInt(11);
            
g_iWallbangs[iClient] = hResults.FetchInt(12);
            
g_iAWPNoscopes[iClient] = hResults.FetchInt(13);
            
g_iSSG08Noscopes[iClient] = hResults.FetchInt(14);
            
g_iEntryKills[iClient] = hResults.FetchInt(15);
            
g_iEntryDeaths[iClient] = hResults.FetchInt(16);
        }
        
        else
        {
            
char sQuery[256];
            
Format(sQuerysizeof(sQuery), "INSERT INTO mugistats (steam_id, name, exp, kills, deaths, headshots, suicides, damage, knifekills, nadekills, rounds_won, rounds_lost, wallbangs, awp_noscopes, ssg08_noscopes, entry_kills, entry_deaths) VALUES (\"%s\", \"%N\", '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')"g_sSteamid[iClient], iClientg_iExp[iClient], g_iKills[iClient], g_iDeaths[iClient], g_iHeadshots[iClient], g_iSuicides[iClient], g_iDamage[iClient], g_iKnifeKills[iClient], g_iNadeKills[iClient], g_iRoundsWon[iClient], g_iRoundsLost[iClient], g_iWallbangs[iClient], g_iAWPNoscopes[iClient], g_iSSG08Noscopes[iClient], g_iEntryKills[iClient], g_iEntryDeaths[iClient]);
            
            
g_hDatabase.Query(SQL_ErrorsQuery);
        }
    }

__________________
Taking requests, add me on Steam.

People make themselves understood in a way, others understand in another.

Last edited by mug1wara; 08-04-2018 at 21:11.
mug1wara is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 08-04-2018 , 20:28   Re: Database messing with me again.
Reply With Quote #2

Print your query string to console and try it in something like myphpadmin.
__________________
Neuro Toxin is offline
Addicted.
AlliedModders Donor
Join Date: Dec 2013
Location: 0xA9D0DC
Old 08-05-2018 , 21:53   Re: Database messing with me again.
Reply With Quote #3

In addition you should also always check the return of GetClientAuthId
Addicted. is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Location: Not your business.
Old 08-06-2018 , 09:39   Re: Database messing with me again.
Reply With Quote #4

That wasn't the case.

Second query, I use 256 buffer size when It's an easy 300+
__________________
Taking requests, add me on Steam.

People make themselves understood in a way, others understand in another.
mug1wara is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 08-06-2018 , 15:28   Re: Database messing with me again.
Reply With Quote #5

Will come back to this. Found more issues.
__________________

Last edited by Maxximou5; 08-07-2018 at 01:05.
Maxximou5 is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-07-2018 , 09:19   Re: Database messing with me again.
Reply With Quote #6

You should use '%s' instead of \"%s\". And don't forget about database.Escape when you insert a name in your database (it can contains quotes or apostrophes)
Ilusion9 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Location: Not your business.
Old 08-07-2018 , 19:01   Re: Database messing with me again.
Reply With Quote #7

Quote:
Originally Posted by Ilusion9 View Post
You should use '%s' instead of \"%s\". And don't forget about database.Escape when you insert a name in your database (it can contains quotes or apostrophes)
Since I used AuthId_Steam2 I decided to escape the quotes because the authtype contains semicolons which split the string.
__________________
Taking requests, add me on Steam.

People make themselves understood in a way, others understand in another.
mug1wara is offline
Reply


Thread Tools
Display Modes

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 15:09.


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