mysql_query生成ERR_EMPTY_RESPONSE

时间:2011-09-23 11:50:50

标签: php mysql wordpress

我们最近在我们的服务器(运行Wordpress)上将PHP版本升级到5.3.3,从那时起mysql_query功能开始挂起服务器,在Google Chrome中产生错误Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data
连接参数正确,错误记录也打开但没有出现。
可能有什么不对?我该怎么检查?

更新:

代码:

function query( $query ) {
    if ( ! $this->ready )
        return false;

    // some queries are made before the plugins have been loaded, and thus cannot be filtered with this method
    if ( function_exists( 'apply_filters' ) )
        $query = apply_filters( 'query', $query );

    $return_val = 0;
    $this->flush();

    // Log how the function was called
    $this->func_call = "\$db->query(\"$query\")";

    // Keep track of the last query for debug..
    $this->last_query = $query;

    if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
        $this->timer_start();

    // use $this->dbh for read ops, and $this->dbhwrite for write ops
    // use $this->dbhglobal for gloal table ops
    unset( $dbh );
    if( defined( 'WP_USE_MULTIPLE_DB' ) && WP_USE_MULTIPLE_DB ) {
        if( $this->blogs != '' && preg_match("/(" . $this->blogs . "|" . $this->users . "|" . $this->usermeta . "|" . $this->site . "|" . $this->sitemeta . "|" . $this->sitecategories . ")/i",$query) ) {
            if( false == isset( $this->dbhglobal ) ) {
                $this->db_connect( $query );
            }
            $dbh =& $this->dbhglobal;
            $this->last_db_used = "global";
        } elseif ( preg_match("/^\\s*(alter table|create|insert|delete|update|replace) /i",$query) ) {
            if( false == isset( $this->dbhwrite ) ) {
                $this->db_connect( $query );
            }
            $dbh =& $this->dbhwrite;
            $this->last_db_used = "write";
        } else {
            $dbh =& $this->dbh;
            $this->last_db_used = "read";
        }
    } else {
        $dbh =& $this->dbh;
        $this->last_db_used = "other/read";
    }

    $this->result = @mysql_query( $query, $dbh );
    $this->num_queries++;

    if ( defined( 'SAVEQUERIES' ) && SAVEQUERIES )
        $this->queries[] = array( $query, $this->timer_stop(), $this->get_caller() );

    // If there is an error then take note of it..
    if ( $this->last_error = mysql_error( $dbh ) ) {
        $this->print_error();
        return false;
    }

    if ( preg_match( "/^\\s*(insert|delete|update|replace|alter) /i", $query ) ) {
        $this->rows_affected = mysql_affected_rows( $dbh );
        // Take note of the insert_id
        if ( preg_match( "/^\\s*(insert|replace) /i", $query ) ) {
            $this->insert_id = mysql_insert_id($dbh);
        }
        // Return number of rows affected
        $return_val = $this->rows_affected;
    } else {
        $i = 0;
        while ( $i < @mysql_num_fields( $this->result ) ) {
            $this->col_info[$i] = @mysql_fetch_field( $this->result );
            $i++;
        }
        $num_rows = 0;
        while ( $row = @mysql_fetch_object( $this->result ) ) {
            $this->last_result[$num_rows] = $row;
            $num_rows++;
        }

        @mysql_free_result( $this->result );

        // Log number of rows the query returned
        // and return number of rows selected
        $this->num_rows = $num_rows;
        $return_val     = $num_rows;
    }

    return $return_val;
}

导致错误的行是$this->result = @mysql_query( $query, $dbh );
我目前正在研究$dbh的价值 没有参数的mysql_query产生了警告,所以至少它是有效的。

0 个答案:

没有答案