所以你有
$sql = "SELECT * FROM `table` WHERE `some_text_field` LIKE CONCAT('%', ?, '%')";
$stmt = $dbh->prepare($sql);
$stmt->execute(array($_POST['badies_code']));
看着另一个问题,我发现这会引起安全问题,但为什么呢?
我发现了这个问题,一个被否决的答案和一个被赞成的评论,这就是我问的原因
评论说
This is not the correct way to do this. You should not use CONCAT() for three static string literals, as it opens you up to a specific type of SQL injection (i forget the name). – Theodore R. Smith
最佳答案
记住不存在的注入(inject)的名称将是一项相当复杂的任务。
将 concat()
与准备好的语句一起使用没有任何问题。
关于php - 为什么不应该将 CONCAT() 用于静态字符串文字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22740375/