CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Jul 2007
    Posts
    609

    mysql string sanitisation

    What would be the best/fastest way to sanitize strings?

    Right now I wrote this function, but I don't know how efficient this really is, nor if I'm even covering all my bases:

    Code:
    		public static string Sanitize(string instr)
    		{
    			string ret=instr;
    			
    			ret=ret.Replace("\\","\\\\");
    			ret=ret.Replace("\"","\\\"");
    			ret=ret.Replace("`","\\`");
    			ret=ret.Replace("\'","\\'");			
    			
    			return ret;
    		}

    Is there a better way to do this?
    Last edited by Red Squirrel; February 21st, 2009 at 03:39 PM.
    http://www.uovalor.com :: Free UO Server

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured