Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

WWW class , php ws, Mysql db

Discussion in 'iOS and tvOS' started by frigorifico, Dec 12, 2014.

  1. frigorifico

    frigorifico

    Joined:
    Sep 5, 2013
    Posts:
    37
    hi all, got a problem i use the www class to connect to a server side php script that will add score to a MySQL DB, i also use de WWW class to receive the high score table info, 7 out of 10 times it works fine, but that is not enough it as to be 10 out of 10.

    i have 2 distinct php files one for the upload of data and one for the download, the download its working fine i use the code
    Code (CSharp):
    1. void get_info()
    2. {
    3.      WWWForm form = new WWWForm();
    4.      form.AddField("id_pers", pers.Id_personagen);
    5.      WWW ww = new WWW(URL_GET_NUM_JOGOS, form);
    6.      StartCoroutine(cr_Num_Jogos(ww));
    7. }
    8.  
    9. IEnumerator cr_Num_Jogos(WWW w)
    10. {
    11.    yield return w;
    12.    print(w.text);
    13. }
    to get info of just one player, this works all the time no problem here.

    to send data to the server i use
    Code (CSharp):
    1. void send_info()
    2. {
    3.      WWWForm form = new WWWForm();
    4.      form.AddField("id_pers", pers.Id_personagen);
    5.      form.AddField("score", pers.score);
    6.      WWW ww = new WWW(URL_SET_NUM_JOGOS, form);  
    7. }
    8.  
    this bit of code works but only 7/10 times maybe less. im sending the info to the server every 10 sec
    i have the same code in Android and WP and it works perfect.
    so i think that my problem is some IOS optimization or limit that i don't know about can some one plz help me and give me 2 or 3 ideas i can try because i think i tried every thing

    thanks in advance.
     
  2. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    You have to tell us what I breaking and what error messages you're getting.
     
  3. tonemcbride

    tonemcbride

    Joined:
    Sep 7, 2010
    Posts:
    1,077
    I had an issue on iOS where safari was internally caching the results when accessing the same URL. If you add a random field onto the URL it might fix it (worked for me). e.g. instead of:

    www.server.com/my.php

    do

    www.server.com/my.php?r=1237812793 (<-- change this in code each time)
     
  4. frigorifico

    frigorifico

    Joined:
    Sep 5, 2013
    Posts:
    37
  5. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,616
    better approach is to put this at the top of your php

    header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");