php anti-sql injection filter code

Source: Internet
Author: User
Keywords Network programming PHP tutorial
Tags anti- code function functions network network programming not to php

We provide three functions not to filter some special characters, the main is to use sql sql-sensitive string to filter out, and the following Let's look at this code. A friend in need take a look.

function phps tutorial ql_show ($ str) {
$ str = stripslashes ($ str);
$ str = str_replace ("& # 92;", "", $ str);
$ str = str_replace ("& # 47;", "/", $ str);
$ str = str_replace ("& # 32;", "", $ str);
$ str = str_replace ("& # 44;", ",", $ str);
return $ str;
}
function phpsql_post ($ str) {
$ str = stripslashes ($ str);
$ str = str_replace ("|", "& # 124;", $ str);
$ str = str_replace ("<", "& # 60;", $ str);
$ str = str_replace (">", "& # 62;", $ str);
$ str = str_replace ("& nbsp;", "& # 32;", $ str);
$ str = str_replace ("", "& # 32;", $ str);
$ str = str_replace ("(", "& # 40;", $ str);
$ str = str_replace (")", "& # 41;", $ str);
$ str = str_replace ("` "," & # 96; ", $ str);
// $ str = str_replace ("'", "& # 39;", $ str);
$ str = str_replace ('' ', "& # 34;", $ str);
$ str = str_replace (",", "& # 44;", $ str);
$ str = str_replace ("$", "& # 36;", $ str);
$ str = str_replace ("", "& # 92;", $ str);
$ str = str_replace ("/", "& # 47;", $ str);
return $ str;
}
function phpsql_replace ($ str) {
$ str = stripslashes ($ str);
$ str = str_replace ("'", "& # 39;", $ str);
return $ str;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.