开发者

mysql_query producing ERR_EMPTY_RESPONSE

We recently had PHP version upgraded to 5.3.3 on our server (running Wordpress) and since then the mysql_query function started hanging the server, producing the error Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data in Google Chrome.

The connection parameters are correct and error logging is also turned on but nothing appears.

What could be wrong? What should I check?

UPDATE:

The code:

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;
}

The line that causes the error is $this->result = @mysql_query( $query, $dbh );

I am currently investigating the value of $dbh.

mysql_query without parameters produced a warning, so at least it is working.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜