Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by mrfilmmkr · Jan 03, 2018 at 01:06 AM · phpsqlutf-8

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 . "<br>" . $conn->error;
 }
 
 $conn->close();
 ?>
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jan 03, 2018 at 01:35 AM

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by mrfilmmkr · Jan 03, 2018 at 02:15 AM

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();
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

72 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Using Unity to connect to a Database 3 Answers

When built for web player, my php doesn't return the datatable. Works just fine in standalone build and while editing. 1 Answer

All about online game, (dedicated host), SQL, any tutorial? how to do it?? 0 Answers

Is it possible to create GameObjects dinamically from a server? 1 Answer

PHP Calls dont work on mobile 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges