Raised This Month: $138 Target: $400
 34% 

[SQL] Error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Had3s99
Member
Join Date: Sep 2015
Location: France
Old 08-18-2019 , 16:38   [SQL] Error
Reply With Quote #1

Hello,

I've my code :

Code:
public void T_SelectPlayerTime(Database db, DBResultSet results, const char[] error, any data) {
	int client = 0;

	if ((client = GetClientOfUserId(data)) == 0) {
		return;
	}
	
	if (results == null) {
		LogError("T_SelectPlayerTime failed! %s", error);
	}
	else if(results.RowCount == 0) {
		char l_sQuery[256];
	
		char l_sPseudo[64];
		char l_sSteamId[64];
		
		GetClientName(client, STRING(l_sPseudo));
		GetClientAuthId(client, AuthId_Steam2, STRING(l_sSteamId));
		
		Time[client] = 0;

		FormatEx(l_sQuery, sizeof(l_sQuery), "INSERT INTO `Time_Players` (Pseudo, SteamId) VALUES ('%s', '%s')", l_sPseudo, l_sSteamId);
		Dbase.Query(T_InsertPlayerTime, l_sQuery, _, DBPrio_Low);
	}
}

public void T_InsertPlayerTime(Database db, DBResultSet results, const char[] error, any data) {
	if (results == null) {
		LogError("T_InsertPlayerTime failed! %s", error);
	}
}
And i've this error :

Code:
L 08/18/2019 - 21:55:10: [csgo_timer.smx] T_InsertPlayerTime failed! 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 'ballz', 'STEAM_1:1:86693297')' at line 1
What is my error ?

Thanks,

Had3s99.
__________________

Last edited by Had3s99; 08-18-2019 at 16:41.
Had3s99 is offline
Farbror Godis
AlliedModders Donor
Join Date: Feb 2016
Old 08-18-2019 , 16:43   Re: [SQL] Error
Reply With Quote #2

I think it may be the ' symbols. As a side note, make it a habit to use Database.Format for queries in the future.
__________________
Farbror Godis is offline
Had3s99
Member
Join Date: Sep 2015
Location: France
Old 08-18-2019 , 16:53   Re: [SQL] Error
Reply With Quote #3

Quote:
Originally Posted by Farbror Godis View Post
I think it may be the ' symbols. As a side note, make it a habit to use Database.Format for queries in the future.
So i've edit like that :

Code:
FormatEx(l_sQuery, sizeof(l_sQuery), "INSERT INTO Time_Players (Pseudo, SteamId) VALUES ('%s', '%s')", l_sPseudo, l_sSteamId);
And do u have exemple about ur 'Database.Format' ?

I don't understand everything cause i'm not very good in english ^^
__________________
Had3s99 is offline
CrazyHackGUT
AlliedModders Donor
Join Date: Feb 2016
Location: Izhevsk, Russia
Old 08-19-2019 , 01:18   Re: [SQL] Error
Reply With Quote #4

Quote:
Originally Posted by Had3s99 View Post
And do u have exemple about ur 'Database.Format' ?
Code:
Dbase.Format(l_sQuery, sizeof(l_sQuery), "INSERT INTO Time_Players (Pseudo, SteamId) VALUES ('%s', '%s')", l_sPseudo, l_sSteamId);
__________________
My english is very bad. I am live in Russia. Learning english language - very hard task for me...
CrazyHackGUT is offline
Send a message via ICQ to CrazyHackGUT Send a message via Skype™ to CrazyHackGUT
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 08-19-2019 , 02:49   Re: [SQL] Error
Reply With Quote #5

change

Code:
FormatEx(l_sQuery, sizeof(l_sQuery), "INSERT INTO `Time_Players` (Pseudo, SteamId) VALUES ('%s', '%s')", l_sPseudo, l_sSteamId);
to

Code:
FormatEx(l_sQuery, sizeof(l_sQuery), "INSERT INTO `Time_Players` (Pseudo, SteamId) VALUES (%s, %s)", l_sPseudo, l_sSteamId);
see if the above helps
__________________
8guawong is online now
Ilusion9
Senior Member
Join Date: Jun 2018
Location: Romania
Old 08-19-2019 , 05:02   Re: [SQL] Error
Reply With Quote #6

PHP Code:
Database.Format(l_sQuerysizeof(l_sQuery), "INSERT INTO `Time_Players` (Pseudo, SteamId) VALUES ('%s', '%s');"l_sPseudol_sSteamId); 
__________________
Ilusion9 is offline
Had3s99
Member
Join Date: Sep 2015
Location: France
Old 09-05-2019 , 19:32   Re: [SQL] Error
Reply With Quote #7

So to fix my problem i've do that :

Dbase.Escape(l_sPseudo, l_sPseudoESC, sizeof(l_sPseudoESC));

And thanks for the Dbase.Format i don't know that ^^

And for the charset 'utf8mb4' it's only available on sourcemod 1.10 ? ^^
__________________

Last edited by Had3s99; 09-05-2019 at 19:33.
Had3s99 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 03:40.


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