function add_player_to_leaderboard(\mysqli $dbh, $player) { $player = strval($player); $sth = $dbh->prepare("SELECT COUNT(*) AS `num_rows` FROM `db_checks` WHERE `username`=? LIMIT 1;"); $sth->bind_param('s', $player); $sth->execute(); $sth->bind_result($num_rows); $sth->fetch(); $player_exists = (bool)($num_rows > 0); // don't think (bool) is necessary but i did it anyways to clarify the meaning $sth->close(); if (!$player_exists) { insert_new_player($dbh, $player); echo "Inserted new entry"; return false; } else { echo "Name exists. - Unfinished "; return true; } }