// Generate a receiver list for given category and maximum receivers
function generateReceiverList ($cat, $receiver, $mode = '') {
// Init variables
- $CAT_TABS = $cat."=%s";
+ $CAT_TABS = '';
$CAT_WHERE = '';
$receiverList = '';
$result = false;
if ($cat > 0) {
// Select category
$CAT_TABS = "LEFT JOIN `{?_MYSQL_PREFIX?}_user_cats` AS c ON d.userid=c.userid";
- $CAT_WHERE = " AND c.cat_id=%s";
+ $CAT_WHERE = sprintf(" AND c.cat_id=%s", $cat);
} // END - if
// Exclude users in holiday?
// Only include HTML receivers
$result = SQL_QUERY_ESC("SELECT d.userid FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED' AND d.`html`='Y'".$CAT_WHERE." ORDER BY d.{?order_select?} {?order_mode?} LIMIT %s",
array(
- $cat,
$receiver
), __FUNCTION__, __LINE__);
} else {
// Include all
$result = SQL_QUERY_ESC("SELECT d.userid FROM `{?_MYSQL_PREFIX?}_user_data` AS d ".$CAT_TABS." WHERE d.`status`='CONFIRMED'".$CAT_WHERE." ORDER BY d.{?order_select?} {?order_mode?} LIMIT %s",
array(
- $cat,
$receiver
), __FUNCTION__, __LINE__);
}