- $result = SQL_QUERY("SELECT userid, refid, points, timemark
-FROM "._MYSQL_PREFIX."_doubler
-WHERE completed='".$done."' AND is_ref='".$ref."'".$ADD."
-ORDER BY timemark ".$sort."
-LIMIT ".$limit, __FILE__, __LINE__);
-
- if (SQL_NUMROWS($result) > 0)
- {
+ $result = SQL_QUERY_ESC("SELECT
+ `userid`, `refid`, `points`, `timemark`
+FROM
+ `{?_MYSQL_PREFIX?}_doubler`
+WHERE
+ `completed`='%s' AND `is_ref`='%s'" . $add . "
+ORDER BY
+ `timemark` %s
+LIMIT %s",
+ array(
+ $done,
+ $ref,
+ $sort,
+ $limit
+ ), __FUNCTION__, __LINE__);
+
+ if (!SQL_HASZERONUMS($result)) {