Using the ranking query and PDO
In some of your comments you have mentioned that you are trying to use PDO to execute the query and you need to find the rank of a specific user. To achieve this you need to sorround the standard ranking query (pretty much what Tim has posted in his answer) with an outer query.
And then, we need to recall that PDO doesn't support multiple statements in a single call to execute. So we do it like this.
$dbh = new PDO(...);
$n = 8; # some value that probably comes from GET or POST
$stmt = $dbh->prepare("SET @rank=0");
$stmt->execute();
$stmt = $dbh->prepare("SELECT * FROM (
SELECT uid,
userName,
pts,
@rank := @rank+1 AS rank
FROM tbl_users
ORDER BY pts DESC,
userName) AS a WHERE uid=?");
$stmt->bindParam(1,$n);
$stmt->execute();
while ($a = $stmt->fetch()) {
print_r($a);
}
Be warned that this query might be a triffle slow if you have a large number of rows in your table.
Other options
There are several other solutions that involve LEFT JOINs with inequality comparisons and CROSS JOINs. These will probably be as slow as or even slower than the current query.
RANK,DENSERANK and ROW_NUMBER functions are only available in MariaDB 10.2 onwards and not available in other flavours of mysql. Unfortunately Mariadb 10.2 isn't recommended for production.