gpt4 book ai didi

php - 如何根据 MySQL 数据库中的禁用词检查输入?

转载 作者:可可西里 更新时间:2023-11-01 08:08:06 31 4
gpt4 key购买 nike

假设,如果我不想在用户名中的任何地方使用“douche”这个词,并且我的数据库中有一个表,其中包含所有被禁止的词...

$q = "SELECT * FROM restrictions WHERE prohibited LIKE '%username%'";
$r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc));

if (mysqli_num_rows($r) !== 0)
{
//username is prohibited
echo "invalid";
}
else
{
...etc

问题是我不知道如何执行会获取部分匹配项的查询(即 Jdoucher 或 douchebag4)。 %username% 部分显然是错误的,我知道。有谁知道如何做到这一点?有可能吗?谢谢。

最佳答案

select *
from restrictions
where locate(prohibited, @username) <> 0

关于php - 如何根据 MySQL 数据库中的禁用词检查输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4474130/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com