AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CSGO] MySQL Insert error (https://forums.alliedmods.net/showthread.php?t=301357)

GoldeneK 09-17-2017 19:57

[CSGO] MySQL Insert error
 
hello i have error:
Code:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''76561198338686774' at line 1
when i tring to insert values to database (code):


Code:

char Query[128];
        char sid[50];
        GetClientAuthId(client, AuthId_SteamID64, sid, 50);
        Format(Query, sizeof(Query), "INSERT INTO `sklepsms_paysafecard` VALUES (0, '%s', '%s', %i);", sid, code, money);
        SQL_Query(DB, Query);

DB: https://scr.hu/8pdpOR
Sorry 4 my bad english

Impact123 09-18-2017 11:34

Re: [CSGO] MySQL Insert error
 
The first step to find errors in a query is to take a look at it. Use
PHP Code:

PrintToServer("Query: '%s'"Query); 

or
PHP Code:

LogMessage("Query: '%s'"Query); 

and post what it says.

ThatKidWhoGames 09-18-2017 13:15

Re: [CSGO] MySQL Insert error
 
As a heads up, you probably will want to use threaded queries instead of regular queries. More info here: https://wiki.alliedmods.net/SQL_(SourceMod_Scripting)

EDIT: I know this doesn't have to do with the issue you're having, but threaded queries are a lot better to run.

CamerDisco 09-18-2017 16:22

Re: [CSGO] MySQL Insert error
 
Probably you should escaping 'code' if you don't escape

Totenfluch 09-18-2017 17:07

Re: [CSGO] MySQL Insert error
 
try

Code:

        char Query[256];
        Format(Query, sizeof(Query), "INSERT INTO `sklepsms_paysafecard` VALUES (null, '%s', '%s', %i);", sid, code, money);

Either your database Primarykey doesn't accept 0 (it's AUTO_INCREMENT) or your query buffers was too small...


All times are GMT -4. The time now is 09:41.

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