MySQL query bugfix in iia_engine.php