sql注入一般是拼接sql语句造成的,从浏览器传来变量username和password,其值分别是1' or '1'='1、a,有的人喜欢这样:sqlstr="select * from users where username=\'"+username+"\'" and password=\'"+password+"\'";经过这条语句后,sqlstr的值为:select * from users where username='1' or '1'='1' and password='a',这条sql语句在数据库中肯定能查到纪录,这样就产生了sql注入,而使用外部变量sql注入就不存在了:sqlstr="select * from users where username=:username and password=:password"