当我在我的网站上运行此脚本时,它不会删除任何行,即使输出显示查询成功(它现在输出写出的删除查询)。当我直接在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 ";
}
屏幕或任何日志中都没有错误消息。
答案 0 :(得分:0)
原来我必须逃脱百分号
('Session opened for %name.', 'Session closed for %name.', 'New user: %name (%email).'))
变为
('Session opened for %%name.', 'Session closed for %%name.', 'New user: %%name (%%email).'))