- // Userid given
- $result = SQL_QUERY_ESC("SELECT `userid` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid` =%s LIMIT 1",
- array(bigintval($userid)), __FUNCTION__, __LINE__);
- } else {
- // Nickname given
- $result = SQL_QUERY_ESC("SELECT `userid` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `nickname`='%s' LIMIT 1",
- array($userid), __FUNCTION__, __LINE__);
- }
+ // Userid given, so try to load user data
+ if (fetchUserData($userid)) {
+ // Load nickname from database
+ $ret = getUserData('nickname');