Raised This Month: $12 Target: $400
 3% 

ReplaceString questions..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KaOs
Senior Member
Join Date: Apr 2004
Old 02-08-2008 , 15:12   ReplaceString questions..
Reply With Quote #1

Hello,
Does anyone know how escapes work with this function? I'm running an SQL query and I need to escape single quotes in a players name.. but I'm not sure if I need to double escape it to compensate for the function itself.

For example.. will this do what I need:
blah = "Quote: ' "
ReplaceString(blah, 25, "'", "\'");
// blah = Quote: \'

OR do I need to:
blah = "Quote: ' "
ReplaceString(blah, 25, "'", "\\'");
// blah = Quote: \'

Anyone? Sorry if im a little complicated lol
__________________
KaOs is offline
Send a message via AIM to KaOs Send a message via MSN to KaOs
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 02-08-2008 , 15:55   Re: ReplaceString questions..
Reply With Quote #2

The second one would be correct...

You might want to take a look at this function: SQL_QuoteString
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
BAILOPAN
Join Date: Jan 2004
Old 02-08-2008 , 22:47   Re: ReplaceString questions..
Reply With Quote #3

Indeed, you should use the provided API call rather than trying to guess at the best replacement tactic.
__________________
egg
BAILOPAN is offline
KaOs
Senior Member
Join Date: Apr 2004
Old 02-08-2008 , 23:13   Re: ReplaceString questions..
Reply With Quote #4

Quote:
Originally Posted by BAILOPAN View Post
Indeed, you should use the provided API call rather than trying to guess at the best replacement tactic.
Well again, vague description is killing me..

Quote:
Quotes a database string for literal insertion. This is not needed for binding strings in prepared statements.
Says it's going to QUOTE a string.. I need to escape quotes in a string.. see what I mean? I never would have guessed.
__________________
KaOs is offline
Send a message via AIM to KaOs Send a message via MSN to KaOs
BAILOPAN
Join Date: Jan 2004
Old 02-09-2008 , 01:07   Re: ReplaceString questions..
Reply With Quote #5

Indeed, you're right, the function should have been called SQL_EscapeString(). In fact I don't know why I called it that.

If you file a bug report I'll rename it.
__________________
egg
BAILOPAN is offline
KaOs
Senior Member
Join Date: Apr 2004
Old 02-09-2008 , 13:38   Re: ReplaceString questions..
Reply With Quote #6

Quote:
Originally Posted by BAILOPAN View Post
Indeed, you're right, the function should have been called SQL_EscapeString(). In fact I don't know why I called it that.

If you file a bug report I'll rename it.
Will do, thanks bailo.
__________________
KaOs is offline
Send a message via AIM to KaOs Send a message via MSN to KaOs
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-09-2008 , 23:05   Re: ReplaceString questions..
Reply With Quote #7

I think I've run into a similar situation as to what KaOs just described. I want to insert a string into a DB that has (single and/or double) quotes in it. Would I use that function to modify the string before I insert it, or would I need to do it via ReplaceString() as mentioned in the OP?
bl4nk is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 02-09-2008 , 23:39   Re: ReplaceString questions..
Reply With Quote #8

Use that function to format the string before you run the query.
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 02-09-2008 , 23:49   Re: ReplaceString questions..
Reply With Quote #9

What's the purpose of the DB handle then?

[edit]

Got the answer from pred and bail in irc. Thanks for the help.

Last edited by bl4nk; 02-10-2008 at 00:16.
bl4nk is offline
KaOs
Senior Member
Join Date: Apr 2004
Old 02-10-2008 , 00:38   Re: ReplaceString questions..
Reply With Quote #10

Quote:
Originally Posted by bl4nk View Post
What's the purpose of the DB handle then?

[edit]

Got the answer from pred and bail in irc. Thanks for the help.
mind sharing?
__________________
KaOs is offline
Send a message via AIM to KaOs Send a message via MSN to KaOs
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 14:43.


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