我想在上线之前检查一下自己。我在互联网上阅读了很多不同的东西,但我想知道这是否会绝对保护我的 SQL 注入代码。如果没有,我需要添加或删除什么?
$idtoapprove = mysql_real_escape_string($_POST['idtoapprove']);
$getcity = $conn->prepare('SELECT city, state FROM needs WHERE ID=:idtoapprove');
$getcity->bindParam(':idtoapprove', $idtoapprove);
$getcity->execute();
$cityrow = $getcity->fetch();
$needcity = $cityrow['city'];
$needstate = $cityrow['state'];
echo "$needcity, $needstate";