-//// TOP referral "hunter"
-$result = SQL_QUERY_ESC("SELECT DISTINCT r.userid, d.".$ADD.", SUM(r.counter) AS refs, d.last_online
-FROM "._MYSQL_PREFIX."_refsystem AS r
-LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
-ON r.userid=d.userid
-WHERE r.counter > 0 AND d.status='CONFIRMED'
-GROUP BY r.userid
-ORDER BY refs DESC, d.last_online DESC
+// Free result
+SQL_FREERESULT($result);
+
+//// TOP referal "hunter"
+$result = SQL_QUERY_ESC("
+SELECT DISTINCT
+ d.userid,
+ SUM(r.counter) AS refs,
+ d.last_online
+FROM
+ `{!_MYSQL_PREFIX!}_user_data` AS d
+LEFT JOIN
+ {!_MYSQL_PREFIX!}_refsystem AS r
+ON
+ r.userid=d.userid
+WHERE
+ r.counter > 0 AND
+ d.`status`='CONFIRMED'
+GROUP BY
+ r.userid
+ORDER BY
+ refs DESC,
+ d.last_online DESC