- }
- }
- if (isset($_POST['ok']))
- {
- foreach ($_POST['cat'] as $cat => $joined)
- {
- switch ($joined)
- {
- case "Y":
- $sql = "";
- $result_user = SQL_QUERY_ESC("SELECT id FROM `{!MYSQL_PREFIX!}_user_cats` WHERE userid=%s AND cat_id=%s LIMIT 1",
- array($UID, bigintval($cat)), __FILE__, __LINE__);
-
- if (SQL_NUMROWS($result_user) == 0)
- {
- $sql = "INSERT INTO `{!MYSQL_PREFIX!}_user_cats` (userid, cat_id) VALUES ('%s','%s')";
- }
- else
- {
- // Free memory
- SQL_FREERESULT($result_user);
- }
+ } // END - if
+ } // END - if
+
+ // Is the form sent?
+ if (isFormSent()) {
+ // Start counting all
+ $count = '0';
+
+ // Go through all entries
+ foreach (postRequestElement('cat') as $categoryId => $joined) {
+ // Ini sql here
+ $sql = '';
+
+ // Has the user joined on this category?
+ switch ($joined) {
+ case 'Y':
+ $result_user = SQL_QUERY_ESC("SELECT `id` FROM `{?_MYSQL_PREFIX?}_user_cats` WHERE `userid`=%s AND `cat_id`=%s LIMIT 1",
+ array(getMemberId(), bigintval($categoryId)), __FILE__, __LINE__);
+
+ // Debug message
+ //* DEBUG: */ logDebugMessage(__FILE__, __LINE__, 'categoryId='.$categoryId.',joined='.$joined.',getMemberId()='.getMemberId().',SQL_HASZERONUMS()='.intval(SQL_HASZERONUMS($result_user)));
+
+ if (SQL_HASZERONUMS($result_user)) {
+ $sql = "INSERT INTO `{?_MYSQL_PREFIX?}_user_cats` (`userid`,`cat_id`) VALUES (%s,%s)";
+ } // END - if
+
+ // Free memory
+ SQL_FREERESULT($result_user);