Hi Simon,
do you have the newest version of the plugin 3.2.2?
An empty query should not find the way from the plugin to the wordpress DB function.
Thread Starter
Simon
(@simonwe)
Yup, using the latest version 3.2.2 as you stated…
If I can help solve this issue please tell me.
I receive many errors like this every day…
Same problem here.
We are using the latest version 3.2.5.
Is there a fix? Can we do anything?
There are 2 wordpress systems running on the same server and only one is causing these errors. They use different databases for sure.
Try this patch in counter_core.php
function mysqlQuery( $kind = '', $sql, $func = '' )
{
global $wpdb;
if (empty($sql)) return; // <- add this line
Thanks but this fragment was already there:
if (empty($sql))
return;
oh, sorry. here is my newest version of the function. just work in progress but it should work. i think the problem is an empty $preparedSql
in case of an error.
function mysqlQuery( $kind = '', $sql, $func = '' )
{
global $wpdb;
if (empty($sql))
return;
$t = microtime(true);
$con = $wpdb->dbh;
if ( is_array($sql) )
{
$sql = array_shift($sql);
$args = $sql;
$preparedSql = $wpdb->prepare($sql, $args);
}
else
$preparedSql = $sql;
if (empty($preparedSql))
return;
$r = false;
if ($kind == 'var')
$r = $wpdb->get_var( $preparedSql );
else if ($kind == 'count')
{
$r = $wpdb->get_var('SELECT COUNT(*) FROM ('.trim($preparedSql,';').') t');
}
else if ($kind == 'rows')
{
$r = $wpdb->get_results( $preparedSql );
}
else
$wpdb->query( $preparedSql );
if ( $this->options['debug'] )
{
$d = number_format( microtime(true) - $t , 5);
$m = sprintf("%.2f", memory_get_usage()/1048576).' MB';
$error = (!$r && mysql_errno($con)) ? '<b style="color:red">ERROR:</b> '.mysql_errno($con).' - '.mysql_error($con).' - ' : '';
$this->queries[] = $func." : <b>$d</b> - $m<br/><code>$preparedSql</code><br/>$error";
$this->queries[0] += $d;
}
return $r;
}
That did the trick.
Thanks a ton!