www.data and string conversion to integer

I am new at Unity but trying to utilize www to get information from php. I have read I think almost all the forum and answer posts.

I get an error message that string is not in correct format? Can anyone help? I am send back the number 10 from php in an echo "10" - I am also wondering is there is other documentation on string parsing other than in the reference guide?

php code ->

<?php

echo "10"
?>

java code ->

This is the code:

function Start () {
//var data : string; 
// call php page;
var www : WWW = new WWW (url);

// Wait for download to complete;
yield www;

// returns back string from php - not in form that is workable;
speedA = www.data;

// parse command seems to work because you can hard code value for speedA;
speeds  = int.Parse(speedA);

}

The first thing you should to do is print www.data and see what exactly it looks like. Most likely, this is not just "10" but maybe "10 plus return" or something like that.

Something like

Debug.Log(string.Format(" x{0}x ", speedA));

should do the trick. If this prints anything else than x10x, like x10 new line x, for instance, that would be the problem. You might try String.Trim() ... that should remove whitespace:

speedA = speedA.Trim();

Of course, for that to work you have to make sure that speedA really is a string but I guess UnityScript should handle that correctly for you.

I thought int.Parse() was C#, but with .Net, learn something new every day. I just converted a JS to C#, and I was using parseInt() in JS (worked fine), replaced with int.Parse() for C#. So you might try speeds = parseInt(speedA);