Hi guys, i created a database in a webhost and exp in it but it is bit retrieving my information.Here’s my script.I get this error.
FormatException: Input string was not in the correct format System.Int32.Parse (System.String s) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/Int32.cs:629) InternetCalls+c__Iterator2.MoveNext () (at Assets/Scripts/Level/InternetCalls.cs:87)
Here’s my script
public class InternetCalls : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void DoLogin(string User,string Pass)
{
WWWForm www = new WWWForm ();
www.AddField ("user", User);
www.AddField ("password", Pass);
WWW w = new WWW ("http://reactivestudios.comuv.com/login.php", www);
StartCoroutine (Login(w, User));
GetXp (User);
}
public void DoRegister(string User,string Pass, string Name)
{
WWWForm www = new WWWForm ();
www.AddField ("user", User);
www.AddField ("password", Pass);
www.AddField ("name", Name);
WWW w = new WWW ("http://reactivestudios.comuv.com/register.php", www);
StartCoroutine (Reg(w));
}
IEnumerator Reg (WWW w)
{
yield return w;
if(w.error == null)
{
//PlayerPrefs.SetString("name", User);
Debug.Log ("Working");
Debug.Log (w.text.ToString());
}
}
IEnumerator Login (WWW w, string User)
{
yield return w;
if(w.error == null)
{
if(w.text == "login-SUCCESS")
{
PlayerPrefs.SetString("name",User);
Debug.Log ("Working");
Application.LoadLevel(1);
}
}
else
{
Debug.Log ("Error:" + w.error.ToString());
}
}
public void GetXp(string User)
{
WWWForm www = new WWWForm ();
www.AddField ("user", User);
WWW w = new WWW ("www.reactivestudios.comuv.com/Exp.php",www);
StartCoroutine (Xp (w));
Debug.Log ("Got Exp");
}
IEnumerator Xp(WWW w)
{
yield return w;
if(w.error == null)
{
Debug.Log (w.text);
Debug.Log ("Working Stats");
int i;
if (int.TryParse(w.text, out i))
{
Debug.Log ("Getting xp Worked Stats");
PlayerPrefs.SetInt("xp",i);
Debug.Log ("Get xp Worked Stats");
}
else
{
Debug.Log("Parsing failed");
Debug.Log(w.text.Length);
}
}
}
}
Eventhough i set my exp in database to 100000 it give me debugs me the length of 169.thanks
NOTE: Someone else formatted your code, you should do it for yourself in the future… so you know, people can read it.