gpt4 book ai didi

mysql - 用于删除的 db_query 在 PHP 代码中不起作用,但直接在 mysql 中执行正常

转载 作者:行者123 更新时间:2023-11-29 18:24:55 24 4
gpt4 key购买 nike

当我在网站上运行此脚本时,即使输出显示查询成功(它暂时输出写出的删除查询),它也不会删除任何行。当我直接在 mysql 中运行查询时,它确实删除了行。

    if (db_query("DELETE FROM {watchdog} WHERE ((type = 'user' AND message IN ('Session opened for %name.', 'Session closed for %name.', 'New user: %name (%email).')) OR type = 'access denied' OR (type = 'smtp' AND message = 'Sending mail to: @to')) AND hostname = '%s'", array($hostname)))
{
echo "<br />DELETE FROM watchdog WHERE ((type = 'user' AND message IN ('Session opened for %name.', 'Session closed for %name.', 'New user: %name (%email).')) OR type = 'access denied' OR (type = 'smtp' AND message = 'Sending mail to: @to')) AND hostname = '$hostname'";
}
else
{
echo "<br />could not delete $hostname ";
}

屏幕上或任何日志中都没有错误消息。

最佳答案

事实证明我必须转义百分号

 ('Session opened for %name.', 'Session closed for %name.', 'New user: %name (%email).')) 

变成了

 ('Session opened for %%name.', 'Session closed for %%name.', 'New user: %%name (%%email).')) 

关于mysql - 用于删除的 db_query 在 PHP 代码中不起作用,但直接在 mysql 中执行正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46279659/

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