Zen Cart Logo
Forums / General Questions / "PHP Fatal error: 1065:Query was empty" in admin

"PHP Fatal error: 1065:Query was empty" in admin

Views: 5,472

Results 1 to 3 of 3
3 Feb 2014, 8:38 AM
#1
plot0808 avatar

plot0808

New Zenner

Join Date:
Jan 2014
Posts:
4
Plugin Contributions:
0

"PHP Fatal error: 1065:Query was empty" in admin

Hi
After switching to PHP 5.4.4 , we started receiving this weird errors in admin upon saving a product. The product is actually updated, but I guess I see this error when the redirect to category.php is done. Log says:

PHP Fatal error: 1065:Query was empty :: in ***/includes/classes/db/mysql/query_factory.php on line 120

We're using Zencart 1.5.1 on PHP 5.4.4 and MySQL 5.5.33.

We are using database caching only in front end (no caching in admin, where this actually happens) and I see that this fix is already applied:

https://github.com/zencart/zencart/commit/64d757322ea59e14df8b5372564f845ca345f247

but I guess it doesn't matter much as when I switch to file based caching in front we keep receiving this error (in admin).

We have lots of mods installed, lots of our own modifications as well, but all worked before and now suddenly we started getting this in admin. I noticed that I get this error in one more area - when I try to send a gift certificate mail via admin. I've read and tried all that I could find in the forum but with no result.

Any help or debug hints will be appreciated!

4 Feb 2014, 8:42 AM
#3
plot0808 avatar

plot0808

New Zenner

Join Date:
Jan 2014
Posts:
4
Plugin Contributions:
0

Re: "PHP Fatal error: 1065:Query was empty" in admin

OK, lat9, that's like the smartest idea I've recevied for years! THANKS VERY MUCH!! ALL SOLVED!
Here's what I did, if it helps someone in future.

I applied the patch.

In logs I received:
PHP Fatal error: 1065:Query was empty :: ==> (as called by) ***/includes/functions/database.php on line 53 <== in ***/includes/classes/db/mysql/query_factory.php on line 132

In databse.php I've added the following:

reset($data);

$customlog = '';
$customlog .= $table.'<br />';
$customlog .= serialize($data).'<br />';
$customlog .= $action.'<br />';
$customlog .= $parameters.'<br />';
$customlog .= $link.'<br />';

if ($action == 'insert') {
...
$query = substr($query, 0, -2) . ')';
}

$customlog .= '<br />>>>>>>>>>>>>>>>><br />';
$customlog .= $query.'<br /><br />';
$customlog .= '<<<<<<<<<<<<<<<<<<<<<<hr />';
file_put_contents('***/logs/custom_log_'.time().'-'.rand(0,9999).'.html',$customlog);

return $db->Execute($query);

Then I triggered the error. In the custom_log file I got:

zen_seo_cache
a:9:{s:8:"cache_id";s:32:"ca34.......-06 00:27:26";}
insert ignore

db_link

<<<<<<<<<<<<<<<<<<<<<

this $action == INSERT IGNORE was missing in zen_db_perform() ifs, I added it and all is working now.

Now, I've had to add this INSERT IGNORE before, when I switched to the new server, because I started getting duplicate key errs from MySQL, when dealing with db caching. So this bug is not in fact native for Zencart, I've opened it when fixing another one. :)

Thanks again!