AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Removing ' from nick (https://forums.alliedmods.net/showthread.php?t=164257)

Backstabnoob 08-09-2011 07:47

Removing ' from nick
 
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?

jim_yang 08-09-2011 07:50

Re: Removing ' from nick
 
try "^'"

Backstabnoob 08-09-2011 07:56

Re: Removing ' from nick
 
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.

jim_yang 08-09-2011 08:06

Re: Removing ' from nick
 
replace_all(name, 31, "^'", "")

Backstabnoob 08-09-2011 08:14

Re: Removing ' from nick
 
Oh, okay, didn't get it soz

jim_yang 08-09-2011 08:16

Re: Removing ' from nick
 
with my test, replace_all(a, sizeof(a)-1, "'", "") is fine too...

Hunter-Digital 08-09-2011 11:36

Re: Removing ' from nick
 
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 ?

Exolent[jNr] 08-09-2011 11:43

Re: Removing ' from nick
 
Quote:

Originally Posted by Hunter-Digital (Post 1528968)
Still, isn't there a safe query input function in amxx already ?

SQL_QuoteString, but not available in threading.


All times are GMT -4. The time now is 03:19.

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