Unity PHP/SQL table creation adds strange characters to table name

I am using the following PHP code which takes in the tableName from Unity using the following c# function where the tableName is actually an email address. I can get the table created just fine, but it seems Unity and SQL have some sort of character/collation issue that I can’t get past.

if the value of tableName is obtained from $_POST, it adds “​” to the end of the tableName. For instance the tableName “myemail@email.com_points” appears with the SQL tableName “myemail@email.com​_points”. If I replace the tableName variable in the below PHP code with a string rather than a _POST variable, the table name appears correctly.

tableName = _POST[‘tableName’]; <------ DOESN’T WORK
$tableName = ‘myemail@email.com_points’; <-------- WORKS

I have changed the character/collation of the database to UTF8_general_ci and to UTF8mb4_general_ci and just about every other suggestion I could find - and nothing works - not even renaming the table once it’s been created. ANY advice would be much appreciated.

C# function:

public void createPointsTable(string tableName)  
	{

		WWWForm data = new WWWForm ();
		data.AddField ("tableName", tableName);

		WWW www = new WWW (createPointsTableUrl, data);
	}

PHP code:

<?php
include_once('db.php');
 
$tableName = $_POST['tableName'];

$sql = "CREATE TABLE `$tableName` (id int NOT NULL AUTO_INCREMENT, kid varchar(255) NOT NULL, doy int NOT NULL, pointsChange int NOT NULL, reason varchar(255) NOT NULL, dailyPoints int NOT NULL, PRIMARY KEY(id), UNIQUE(id))";

$result = mysqli_query($conn, $sql);

if ($conn->query($sql) === TRUE) {
    echo "Table Created";
} else {
    echo "Error: " . $sql . "

" . $conn->error;
}

$conn->close();
?>

The character sequence “​” is equivalent to the hexadecimal sequence E2 80 8B which seems to be the UTF8 encoding for a zero width space character.

Since it looks like you concat “_points” to the email address already on the Unity side you may want to check the address for illegal characters before you concat and form the table name.

I figured out the issue. I needed to convert the text from the input field to a string and then trim it.

newTableName = tableName.ToString().Trim();