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

[CSGO] MySQL Insert error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoldeneK
Member
Join Date: Oct 2016
Old 09-17-2017 , 19:57   [CSGO] MySQL Insert error
Reply With Quote #1

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
GoldeneK is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 09-18-2017 , 11:34   Re: [CSGO] MySQL Insert error
Reply With Quote #2

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.
__________________

Last edited by Impact123; 09-18-2017 at 11:47.
Impact123 is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 09-18-2017 , 13:15   Re: [CSGO] MySQL Insert error
Reply With Quote #3

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.

Last edited by ThatKidWhoGames; 09-18-2017 at 13:16.
ThatKidWhoGames is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 09-18-2017 , 16:22   Re: [CSGO] MySQL Insert error
Reply With Quote #4

Probably you should escaping 'code' if you don't escape
__________________


Max-Play.pl - the best polish servers

Last edited by CamerDisco; 09-18-2017 at 16:30.
CamerDisco is offline
Totenfluch
AlliedModders Donor
Join Date: Jan 2012
Location: Germany
Old 09-18-2017 , 17:07   Re: [CSGO] MySQL Insert error
Reply With Quote #5

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...
__________________
Notable Projects:
Event Item Spawner | Scissors, Rock, Paper for ZephStore
tVip | Smart Link Remover
PLG & GGC - CS:GO Roleplay

and countless more...

I can make a helicopter shoot missles if you want me to...

Last edited by Totenfluch; 09-18-2017 at 17:08.
Totenfluch 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 11:38.


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