Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mysql_real_escape_string for nodejs

function mysql_real_escape_string (str) {
    return str.replace(/[x08x09x1a

"'\%]/g, function (char) {
        switch (char) {
            case "":
                return "";
            case "x08":
                return "";
            case "x09":
                return "	";
            case "x1a":
                return "z";
            case "
":
                return "
";
            case "
":
                return "
";
            case """:
            case "'":
            case "":
            case "%":
                return ""+char; // prepends a backslash to backslash, percent,
                                  // and double/single quotes
        }
    });
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nodejs
ADD COMMENT
Topic
Name
6+1 =