Search Unity

Issues with WWWForm - necessary data rewind wasn't possible

Discussion in 'Scripting' started by fxjeane, Oct 18, 2010.

Thread Status:
Not open for further replies.
  1. fxjeane

    fxjeane

    Joined:
    Oct 18, 2010
    Posts:
    4
    Hello there. Im trying to send data to a php script with WWW and WWWForm. It was working before but at some point it stopped. Suddenly i keep getting a "necessary data rewind wasn't possible" errror. As soon as I comment out all the "AddField"s or not include the form in the WWW call it works perfectly.

    Any ideas?

    This is the code of my jscript function

    Code (csharp):
    1. function Start() {
    2.  
    3. var highscore_url = "http://example.com/script.php";
    4. var form = new WWWForm();
    5. form.AddField( "var1", "value1" );
    6. form.AddField( "var2", "value2");
    7.  
    8. var www = new WWW( highscore_url, form );
    9.  
    10. // wait for request to complete
    11. yield www;
    12.  
    13. // and check for errors
    14. if (www.error == null)
    15. {
    16.     // request completed!
    17. } else {
    18.     // something wrong!
    19.     Debug.Log("WWW Error: "+ www.error);
    20. }
    21.  
    and this is the php file

    PHP:
    <?php
    echo json_encode($_POST);
    ?>
     
  2. fxjeane

    fxjeane

    Joined:
    Oct 18, 2010
    Posts:
    4
    So. I have tried to use the exact same code outlined here

    http://unity3d.com/support/documentation/ScriptReference/WWWForm.html

    for handling form submissions. I am using the same javascript and perl code and I still get this error

    Error downloading: necessary data rewind wasn't possible
    UnityEngine.MonoBehaviour:print(Object)


    can someone please help me. If i cant submit data to my servers then unity becomes completely useless to me.

    Sincerely
    Rudy
     
  3. fxjeane

    fxjeane

    Joined:
    Oct 18, 2010
    Posts:
    4
    Anyone? This is really holding me back

    Cheers
     
  4. fxjeane

    fxjeane

    Joined:
    Oct 18, 2010
    Posts:
    4
    i figured it out. Im posting the solution for future reference.

    in my WWW i was calling "http://myserver.com/myscript.php". The problem was that my server is set to rewrite/re-direct all http://myserver.com calls into http://www.myserver.com. Once I changed the url to contain www. it worked.

    Cheers
     
    Ony, elhongo and glitchers like this.
  5. jono

    jono

    Joined:
    Feb 28, 2008
    Posts:
    2
    Hi fxjeane / future data rewind problem-hitters,
    We just ran into and solved this one -- our PHP script was redirecting ( header("Location:http://....") ). Removing this redirect fixed the problem for us.

    Cheers!
     
    Ony likes this.
  6. ess

    ess

    Joined:
    Jul 4, 2012
    Posts:
    1
    @jono. You are a LIFESAVER. THANK YOU.
     
  7. superme2012

    superme2012

    Joined:
    Nov 5, 2012
    Posts:
    207
    To add to this, make sure you attach the script to an empty game object, and not the camera that is loaded as default. Trust me, when I say F*sakes.

    echo json_encode($_POST);

    nice ;)
     
  8. BernieRoehl

    BernieRoehl

    Joined:
    Jun 24, 2010
    Posts:
    80
    Many thanks, jono! I had exactly the same problem just now, and your post saved me a whole bunch of time and aggravation.
     
  9. tekkers0751

    tekkers0751

    Joined:
    Apr 17, 2013
    Posts:
    2
    @superme2012, thank you so much for your help, been trying to figure it out for ages, many thanks! :)
     
  10. breban1

    breban1

    Joined:
    Jun 7, 2016
    Posts:
    194
    @fxjeane thanks this worked for me!
     
  11. sachin_unity930

    sachin_unity930

    Joined:
    Feb 28, 2022
    Posts:
    3
    I am using this without subdomain means I am using http://128.0.0.255/
    i am sharing wrong ip address but i am using like this. so now what solution works for me because this issue occur in some machine or not all the time.
     
  12. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,486
    This post is 12 years old. Please don't necro threads, create your own.
     
Thread Status:
Not open for further replies.