PHP速学视频免费教程(入门到精通)
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
<?phptry { $db = new pdo("mysql:host=localhost;dbname=mtest;charset=utf8", 'root', 'root'); $db -> setattribute(pdo::attr_emulate_prepares, false); $stmt = $db -> prepare("select * from zhuru where _id=:usid "); $usid = '1001 and 1=0'; $stmt->bindparam(':usid',$usid,pdo::param_int); $exer = $stmt -> execute(); while ($rows = $stmt -> fetch(pdo::fetch_assoc)) { echo $rows['username'].'------' . $rows['nickname'].'<br><br>'; } $db = null;} catch(pdoexception $e) { echo $e -> getmessage();}
select * from zhuru where _id=:usid
实际执行的是
select * from zhuru where _id='1001 and 1=0'
不可能满足条件
退一步说,即便不给你加上单引号,执行的也是
select * from zhuru where _id=1001 and 1=0
1=0 恒为假,表达式不会成立,自然也就找不到
问题是查询到了_id=1001的用户的信息。
select * from zhuru where _id=:usid
实际执行的是
select * from zhuru where _id='1001 and 1=0'
不可能满足条件
退一步说,即便不给你加上单引号,执行的也是
select * from zhuru where _id=1001 and 1=0
1=0 恒为假,表达式不会成立,自然也就找不到
实际执行的是
select * from zhuru where _id='1001 and 1=0'
因为 _id 是 int 类型,'1001 and 1=0' 转换为数值是 1001,可以满足条件
实际执行的是
select * from zhuru where _id='1001 and 1=0'
因为 _id 是 int 类型,'1001 and 1=0' 转换为数值是 1001,可以满足条件
已抢6799个
抢已抢91599个
抢已抢14416个
抢已抢50595个
抢已抢190537个
抢已抢86251个
抢