PHP mysql injection protection

前端 未结 6 1536
野性不改
野性不改 2020-12-10 17:53

I have written this short function to protect against my_sql injection, because of its importance I just want to double check with other\'s that this will function as I inte

6条回答
  •  攒了一身酷
    2020-12-10 18:02

    If you use PDO (properly) you don't have to worry about MySQL injection.

    Sample:

    /* Execute a prepared statement by passing an array of insert values */
    $calories = 150;
    $colour = 'red';
    $sth = $dbh->prepare('SELECT name, colour, calories
        FROM fruit
        WHERE calories < :calories AND colour = :colour');
    $sth->execute(array(':calories' => $calories, ':colour' => $colour));
    

    More information

提交回复
热议问题