Raised This Month: $ Target: $400
 0% 

Help with SQL querry


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
IT_Prof
New Member
Join Date: Jun 2008
Old 02-02-2009 , 06:04   Help with SQL querry
Reply With Quote #1

Sorry for my bad English.

In my game servers admins in the AMXBans database identified by SteamID. In the Nickname field identifies the real nicknames of admins.
When an admin ban player in the database is stored admin nick from game, not a real nickname. I need to admin real nickname taken from a database.

From cmdban.inl ->
Quote:
public cmd_ban_(failstate, Handle:query, error[], errnum, data[], size)
new admin_nick[100], admin_steamid[50], admin_ip[20]
get_user_name(id, admin_nick, 99)
get_user_ip(id, admin_ip, 19, 1)
I need:
Quote:
new admin_nick[100], admin_steamid[50], admin_ip[20]
get_user_name(id, admin_nick, 99)

get_user_authid(id, admin_steamid, 49)
new query[1024]
format(query,1023,"SELECT amx_amxadmins.nickname FROM amx_amxadmins WHERE amx_amxadmins.username = '%admin_steamid'", admin_nick)
.................................
How to make correctly request in database?

Last edited by IT_Prof; 02-02-2009 at 09:09.
IT_Prof is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-02-2009 , 09:14   Re: Help with SQL querry
Reply With Quote #2

I think you want something like this:

Code:
format(query,1023,"SELECT nickname FROM amx_amxadmins WHERE username='%s'",admin_nick)



or this:

Code:
format(query,1023,"SELECT nickname FROM amx_amxadmins WHERE authid='%s'",admin_steamid)

Also, make sure you escape the player's name before formatting or you could end up with a nasty injection exploit.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
IT_Prof
New Member
Join Date: Jun 2008
Old 02-02-2009 , 12:16   Re: Help with SQL querry
Reply With Quote #3

Quote:
Originally Posted by Hawk552 View Post
I think you want something like this:

Code:
format(query,1023,"SELECT nickname FROM amx_amxadmins WHERE authid='%s'",admin_steamid)
Yes, this is right string!
But this command does not perform query to the database, it only formats (preparing) the request.

How do the query?
IT_Prof is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-02-2009 , 12:28   Re: Help with SQL querry
Reply With Quote #4

Read this:
http://forums.alliedmods.net/showthread.php?t=46779
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
IT_Prof
New Member
Join Date: Jun 2008
Old 02-03-2009 , 04:35   Re: Help with SQL querry
Reply With Quote #5

Quote:
Originally Posted by Hawk552 View Post
Thank you very much! That's exactly what I need!
IT_Prof is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 02-02-2009 , 13:20   Re: Help with SQL querry
Reply With Quote #6

HAWK HAI!!

And hawk, hai

and you shouldn't need blah.field it should be assumed...
Styles is offline
Send a message via AIM to Styles
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 01:48.


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