There's a bug in your PHP code.
Find this line of code:
$nameArray[] = "";
Replace to this line of code:
$nameArray = array();
Update
Find this line of code:
$query = "SELECT name, COUNT(*) AS dupes FROM people GROUP BY name ORDER BY dupes DESC LIMIT 20;";
Replace to this line of code
$query = "SELECT name, COUNT(*) AS dupes FROM people GROUP BY name ORDER BY dupes DESC LIMIT 20";
Note the semicolon inside the string.
Update Once Again
Find this line of code:
while ($row = $mysqli_fetch_array($result)) {
Replace to this line of code
while ($row = mysqli_fetch_array($result)) {
mysqli_fetch_array
is a function.