Search Unity

How to send string list with WWWForm to MySQL?

Discussion in 'Scripting' started by Slyrfecso1, Dec 9, 2015.

  1. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    Hi,

    I'd like to know how can I send list to my MySQL database.
    I have full working login with PHPs and with database.
    I'd like to save everything on my scene.
    Whit one string is working well, but when I try whit more then I can't add them to WWWform.

    Code (CSharp):
    1. public List<string> saveName;
    2. //...
    3. GameObject[] objects = GameObject.FindGameObjectsWithTag("Player");
    4.                     foreach (GameObject go in objects)
    5.                     {
    6.                         go.name = go.name.Replace("Ü","U").Trim();
    7.                         saveName.Add (go.name);
    8.                     }
    9. //...
    10. IEnumerator SaveNames () {
    11. WWWForm Form1 = new WWWForm ();
    12. Form1.AddField ("saveNameE", saveName); //It is working only when it is ONE string!
    13. //...
    14. }
    15.  
     
    Last edited: Dec 10, 2015
  2. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    Code (CSharp):
    1. public struct saveddata
    2.     {
    3.         public string savedName;
    4.         public float savedposx, savedposy, savedposz, savedrotx, savedroty, savedrotz;
    5.     }
    6.  
    7.     public List<saveddata> savedItems = new List<saveddata>();
    8.  
    9.  
    10. ...
    11.  
    12. GameObject[] objects = GameObject.FindGameObjectsWithTag("Player");
    13.                     foreach (GameObject go in objects)
    14.                     {
    15.                         saveddata itm = new saveddata();
    16.                         go.name = go.name.Replace("Ü","U").Trim();
    17.  
    18.                         itm.savedName = go.name;
    19.                         itm.savedposx = float.Parse(go.transform.position.x.ToString());
    20.                         itm.savedposy = float.Parse(go.transform.position.y.ToString());
    21.                         itm.savedposz = float.Parse(go.transform.position.z.ToString());
    22.                         itm.savedrotx = float.Parse(go.transform.rotation.x.ToString());
    23.                         itm.savedroty = float.Parse(go.transform.rotation.y.ToString());
    24.                         itm.savedrotz = float.Parse(go.transform.rotation.z.ToString());
    25.                         savedItems.Add(itm);
    26.                     }
    27.  
    28.  
    29. ...
    30. Form1.AddField ("savedItemsE", savedItems.ToString());
     
    Last edited: Dec 13, 2015
  3. Slyrfecso1

    Slyrfecso1

    Joined:
    Jul 16, 2012
    Posts:
    100
    How can I open the list what I got back from server?
    I used the textSplit and I know exactly which index is the list.
    What I need to write in foreach to open the generic list?


    Code (CSharp):
    1. if (LogText.Contains("Success"))
    2.             {
    3.                 data = LoadAccountWWW.text.Split(':');
    4.  
    5.                 for (int i = 0; i < data.Length; i++)
    6.                     {
    7.                     //Debug.Log(data[i]); //each split
    8.  
    9.  
    10.                 if ( i == 0)
    11.                 {
    12.                 vezetek1 = data [0];
    13.                 osszeallitas1 = data [1];
    14.                 loadItems1 = data[2];
    15.                 }

    Code (CSharp):
    1. foreach(saveddata obj in loadItems1)
    2.                                 {
    3.                                    ...
    4.                                 }

    Any idea will be helpful!