Issues with WWWForm - necessary data rewind wasn't possible

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

function Start() {

var highscore_url = "http://example.com/script.php";
var form = new WWWForm();
form.AddField( "var1", "value1" );
form.AddField( "var2", "value2");

var www = new WWW( highscore_url, form );

// wait for request to complete
yield www;

// and check for errors
if (www.error == null)
{
    // request completed!
} else {
    // something wrong!
    Debug.Log("WWW Error: "+ www.error);
}

and this is the php file

<?php
echo json_encode($_POST);
?>

So. I have tried to use the exact same code outlined here

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

Anyone? This is really holding me back

Cheers

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

3 Likes

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!

1 Like

@jono. You are a LIFESAVER. THANK YOU.

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 :wink:

Many thanks, jono! I had exactly the same problem just now, and your post saved me a whole bunch of time and aggravation.

@superme2012, thank you so much for your help, been trying to figure it out for ages, many thanks! :slight_smile:

@anon_72396587 thanks this worked for me!

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.

This post is 12 years old. Please don’t necro threads, create your own.