$totalPoints = 0;
while ($content = SQL_FETCHARRAY($result_depths)) {
// Load referal points
- $result_points = SQL_QUERY_ESC("SELECT `points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_dept`h=%d LIMIT 1",
+ $result_points = SQL_QUERY_ESC("SELECT `points` FROM `{?_MYSQL_PREFIX?}_user_points` WHERE `userid`=%s AND `ref_depth`='%s' LIMIT 1",
array(getUserId(), bigintval($content['level'])), __FILE__, __LINE__);
// Entry found?
SQL_FREERESULT($result);
// Check for his payouts
- $result_payouts = SQL_QUERY_ESC("SELECT p.id, p.payout_total, p.target_account, p.target_bank, t.type, p.payout_timestamp, p.status, t.allow_url AS allow, p.target_url AS url, p.link_text AS alt, p.banner_url AS banner
-FROM `{?_MYSQL_PREFIX?}_user_payouts` AS p
-LEFT JOIN `{?_MYSQL_PREFIX?}_payout_types` AS t
-ON p.payout_id = t.id
-WHERE p.userid = %s
-ORDER BY p.payout_timestamp DESC",
+ $result_payouts = SQL_QUERY_ESC("SELECT
+ p.id, p.payout_total, p.target_account, p.target_bank, t.type, p.payout_timestamp, p.status, t.allow_url AS allow, p.target_url AS url, p.link_text AS alt, p.banner_url AS banner
+FROM
+ `{?_MYSQL_PREFIX?}_user_payouts` AS p
+LEFT JOIN
+ `{?_MYSQL_PREFIX?}_payout_types` AS t
+ON
+ p.payout_id = t.id
+WHERE
+ p.userid = %s
+ORDER BY
+ p.payout_timestamp DESC",
array(getUserId()), __FILE__, __LINE__);
if (SQL_NUMROWS($result_payouts) > 0) {
// List all his requests
if (SQL_NUMROWS($result) == 1) {
// ID is valid so load the data
$content = SQL_FETCHARRAY($result);
- SQL_FREERESULT($result);
// Calculate maximum value
$max = round($totalPoints * $content['rate'] - 0.5);
// ID is invalid
loadTemplate('admin_settings_saved', false, getMessage('PAYOUT_ID_INVALID'));
}
+
+ // Free result
+ SQL_FREERESULT($result);
}
// [EOF]