-$result = SQL_QUERY_ESC("SELECT DISTINCT d.userid, d.gender, d.surname, d.family, d.email, d.joined, d.last_online, d.ap_notified
-FROM "._MYSQL_PREFIX."_user_data AS d
-WHERE d.status='CONFIRMED' AND d.joined < (UNIX_TIMESTAMP() - %s) AND d.last_online < (UNIX_TIMESTAMP() - %s) AND d.ap_notified < (UNIX_TIMESTAMP() - %s)
-".$EXCLUDE_LIST."
-ORDER BY d.userid", array($_CONFIG['ap_inactive_since'], $_CONFIG['ap_inactive_since'], $_CONFIG['ap_inactive_since']), __FILE__, __LINE__);
+$result = SQL_QUERY_ESC("SELECT
+ d.userid, d.gender, d.surname, d.family, d.email, d.joined, d.last_online, d.ap_notified
+FROM
+ `{?_MYSQL_PREFIX?}_user_data` AS d
+WHERE
+ d.`status`='CONFIRMED' AND
+ d.joined < (UNIX_TIMESTAMP() - %s) AND
+ d.last_online < (UNIX_TIMESTAMP() - %s) AND
+ d.ap_notified < (UNIX_TIMESTAMP() - %s)
+ ".$EXCLUDE_LIST."
+ORDER BY
+ d.userid ASC",
+ array(
+ getConfig('ap_inactive_since'),
+ getConfig('ap_inactive_since'),
+ getConfig('ap_inactive_since')
+ ), __FILE__, __LINE__);