PHP简单strip_tags和truncate字符串错误:连接重置

时间:2011-09-13 00:17:06

标签: php apache

我有以下代码,从管理区域保存后会创建HTML内容正文的副本。问题是如果我将max_length设置为160以上,我会收到连接重置错误。

我的代码有问题吗?或者这对于apache / php来说是否太简单了?

content_body可以是从TinyMCE输入的大块HTML文本。

if($oRequest->get("contents.content_body")){
    $max_length = 255;
    $long_text = strip_tags(trim($oRequest->get("contents.content_body")));

    if(strlen($long_text) > $max_length){
        $short_text = (substr($long_text,0,$max_length));
    } else {
        $short_text = $long_text;
    }

    try {   
        $db = Db_Connections::getInstance()->getConnection();   
        $sql = "UPDATE `contents` SET `content_body_short` = '".mysql_real_escape_string($short_text)."' WHERE content_id = ".(int)$contentID;
        $db->query($sql);       
    } catch (Exception $e) {    
        throw $e;
    }
}

编辑:

我尝试过添加超时(0),这没有什么区别。

错误日志不确定这是否有帮助

[Tue Sep 13 11:10:25 2011] [notice] Parent: child process exited with status 255 -- Restarting.
[Tue Sep 13 11:10:26 2011] [notice] Apache/2.2.17 (Win32) PHP/5.3.4 configured -- resuming normal operations
[Tue Sep 13 11:10:26 2011] [notice] Server built: Oct 24 2010 13:33:15
[Tue Sep 13 11:10:26 2011] [notice] Parent: Created child process 2964
[Tue Sep 13 11:10:26 2011] [notice] Child 2964: Child process is running
[Tue Sep 13 11:10:26 2011] [notice] Child 2964: Acquired the start mutex.
[Tue Sep 13 11:10:26 2011] [notice] Child 2964: Starting 64 worker threads.
[Tue Sep 13 11:10:26 2011] [notice] Child 2964: Starting thread to listen on port 80.
编辑:我发现这只发生在我的本地开发环境中并在我的Debain Squeeze服务器上完美运行

本地设置:

  • WAMP 2.1
  • Apache 2.2.17
  • PHP 5.3.4
  • MYSQL 5.1.53
  • pdo_mysql:mysqlnd 5.0.7-dev - 091210 - $ Revision:304625 $
  • pdo_sqlite:SQLite Library 3.7.3

1 个答案:

答案 0 :(得分:0)

你的apache,连接是否因为apache孩子摔倒时有时会出现错误,这可能有很多原因。

  • PHP 5.3.4在线程上下文中有一些变化,可能会使其不稳定
  • 在线程工作者中使用php,php在线程化环境中总会遇到麻烦

我被告知您正在使用win32,所以可以尝试:

  • 使用更稳定的apache / php包(wamp and that things)
  • 降级php。
  • 更改为apache的无线程mpm

希望这对你有所帮助,祝你有个美好的一天。