【问题标题】:db_query for delete is not working in PHP code, but is executing fine directly in mysql用于删除的 db_query 在 PHP 代码中不起作用,但直接在 mysql 中执行得很好
【发布时间】:2017-09-18 12:46:50
【问题描述】:

当我在我的站点上运行此脚本时,它不会删除任何行,即使输出显示查询成功(它现在输出写出的删除查询)。当我直接在 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 ";
    }

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

【问题讨论】:

    标签: mysql drupal-6


    【解决方案1】:

    原来我不得不逃避百分号

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

    变成

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-18
      • 2019-06-27
      • 2015-09-16
      • 1970-01-01
      • 2013-11-30
      • 2011-01-02
      • 1970-01-01
      相关资源
      最近更新 更多