Raised This Month: $ Target: $400
 0% 

Removing ' from nick


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-09-2011 , 07:47   Removing ' from nick
Reply With Quote #1

Hello, if someone has single quotes in nick name (pwn'd), my plugin that uses SQL connection crashes if it tries to put the nickname into database because of non-escaped character that breaks the query. I tried removing it from the nickname by using replace(name, 31, "'", ""), but it didn't do anything; the single quotes still remain not removed.

How can I possibly remove the single quotes from one's nickname?
Backstabnoob is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 08-09-2011 , 07:50   Re: Removing ' from nick
Reply With Quote #2

try "^'"
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-09-2011 , 07:56   Re: Removing ' from nick
Reply With Quote #3

Escaping like ^' doesn't work in MySQL, it has to be defined in database which I don't have access to.
// I just want to remove the ' character from the string, but as I said, replace(name, 31, "'", "") does nothing.

Last edited by Backstabnoob; 08-09-2011 at 08:06.
Backstabnoob is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 08-09-2011 , 08:06   Re: Removing ' from nick
Reply With Quote #4

replace_all(name, 31, "^'", "")
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Backstabnoob
BANNED
Join Date: Feb 2009
Location: Iwotadai Dorm
Old 08-09-2011 , 08:14   Re: Removing ' from nick
Reply With Quote #5

Oh, okay, didn't get it soz
Backstabnoob is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 08-09-2011 , 08:16   Re: Removing ' from nick
Reply With Quote #6

with my test, replace_all(a, sizeof(a)-1, "'", "") is fine too...
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-09-2011 , 11:36   Re: Removing ' from nick
Reply With Quote #7

You could just add \ in front of any single quotes so that the stored name contains the ' but doesn't affect the SQL query.

Still, isn't there a safe query input function in amxx already ?
__________________
Hunter-Digital is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-09-2011 , 11:43   Re: Removing ' from nick
Reply With Quote #8

Quote:
Originally Posted by Hunter-Digital View Post
Still, isn't there a safe query input function in amxx already ?
SQL_QuoteString, but not available in threading.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] 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:19.


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