当前位置 : 主页 > 网络编程 > PHP >

PHP PDO操作mysql不注意的话依然存在SQL注入

来源:互联网 收集:自由互联 发布时间:2021-06-30
?php dbh = new PDO("mysql:host=localhost; dbname=demo", "user", "pass");$dbh-setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $dbh-exec("set names 'utf8'");$sql="select * from test where name = ? and password = ?";$stmt = $dbh-prepare($sql)
<?php 
dbh = new PDO("mysql:host=localhost; dbname=demo", "user", "pass");
$dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); 
$dbh->exec("set names 'utf8'");
$sql="select * from test where name = ? and password = ?";
$stmt = $dbh->prepare($sql);
$exeres = $stmt->execute(array($name, $pass));
上一篇:php ping端口
下一篇:php mvc框架
网友评论