Php mysql\u查询生成ERR\u EMPTY\u响应
最近,我们的服务器(运行Wordpress)上的PHP版本升级到了5.3.3,从那时起,Php mysql\u查询生成ERR\u EMPTY\u响应,php,mysql,wordpress,Php,Mysql,Wordpress,最近,我们的服务器(运行Wordpress)上的PHP版本升级到了5.3.3,从那时起,mysql\u query函数开始挂起服务器,产生错误error 324(net::ERR\u EMPTY\u RESPONSE):服务器关闭了连接,没有在Google Chrome中发送任何数据。 连接参数正确,错误记录也已打开,但没有显示任何内容。 有什么不对劲吗?我应该检查什么 更新: 守则: function query( $query ) { if ( ! $this->ready )
mysql\u query
函数开始挂起服务器,产生错误error 324(net::ERR\u EMPTY\u RESPONSE):服务器关闭了连接,没有在Google Chrome中发送任何数据。
连接参数正确,错误记录也已打开,但没有显示任何内容。
有什么不对劲吗?我应该检查什么
更新:
守则:
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;
}
函数查询($query){
如果(!$this->ready)
返回false;
//有些查询是在插件加载之前进行的,因此无法使用此方法进行筛选
if(函数_存在('apply_filters'))
$query=应用过滤器('query',$query);
$return\u val=0;
$this->flush();
//记录函数的调用方式
$this->func\u call=“\$db->query(\“$query\”);
//跟踪要调试的最后一个查询。。
$this->last_query=$query;
if(已定义('savequerys')&&savequerys)
$this->timer_start();
//读操作使用$this->dbh,写操作使用$this->dbhwrite
//使用$this->dbhglobal进行全局表操作
unset($胸径);
if(已定义('WP\U USE\U MULTIPLE\U DB')&&WP\U USE\U MULTIPLE\U DB){
如果($this->blogs!=''&&preg_匹配(“/($this->blogs.”|“$this->users.”|“$this->usermeta.”|“$this->sitemata.”|“$this->sitegories.”/i“,$query)){
if(false==isset($this->dbhglobal)){
$this->db\u connect($query);
}
$dbh=&$this->dbhglobal;
$this->last_db_used=“global”;
}elseif(preg|u match(“/^\\s*(alter table | create | insert | delete | update | replace)/i”,$query)){
if(false==isset($this->dbhwrite)){
$this->db\u connect($query);
}
$dbh=&$this->dbhwrite;
$this->last_db_used=“write”;
}否则{
$dbh=&$this->dbh;
$this->last_db_used=“read”;
}
}否则{
$dbh=&$this->dbh;
$this->last_db_used=“other/read”;
}
$this->result=@mysql\u query($query,$dbh);
$this->num_查询++;
if(已定义('savequerys')&&savequerys)
$this->querys[]=array($query,$this->timer\u stop(),$this->get\u caller());
//如果有错误,请记下。。
如果($this->last_error=mysql_error($dbh)){
$this->print_error();
返回false;
}
if(preg|u match(“/^\\s*(插入|删除|更新|替换|更改)/i”,$query)){
$this->rows\u impacted=mysql\u impacted\u rows($dbh);
//注意insert_id
if(preg_match(“/^\\s*(插入|替换)/i“,$query)){
$this->insert\u id=mysql\u insert\u id($dbh);
}
//返回受影响的行数
$return\u val=$this->rows\u受影响;
}否则{
$i=0;
而($i<@mysql\u num\u字段($this->result)){
$this->col\u info[$i]=@mysql\u fetch\u字段($this->result);
$i++;
}
$num_行=0;
而($row=@mysql\u fetch\u object($this->result)){
$this->last_result[$num_rows]=$row;
$num_rows++;
}
@mysql\u free\u result($this->result);
//记录查询返回的行数
//并返回所选的行数
$this->num\u rows=$num\u rows;
$return\u val=$num\u行;
}
return$return\u val;
}
导致错误的行是$this->result=@mysql\u query($query,$dbh)代码>
我目前正在调查$dbh
mysql\u查询
没有参数会产生一个警告,所以至少它是工作的。如果没有执行mysql\u查询
的php代码投票关闭,这个问题是无法回答的。当使用空参数(“”,“”)调用mysql\u查询函数时,我得到了一个正确的警告,这意味着该函数本身正在工作,但是,一旦传递第二个(连接)参数,就会发生ERR_EMPTY_响应错误。在类构造函数中成功创建连接参数。但是连接显然存在一些问题。我会回显您正在运行的查询$query
,看看它是否是有效的SQL。此外,php中的动态查询构建听起来像是一场安全噩梦:我尝试使用空查询“”,或者非常简单的东西,比如从wp\u options中选择选项\u name、选项\u value,其中autoload='yes'。在这两种情况下,都会出现空响应错误。这可能与PHP或MySQL配置有关,还是与PHP在*nix上以CGI运行有关?