Input string was not in the correct format

Anybody know why this error is happening?
Input string was not in the correct format System.Int32.Parse (System.String s)
This is my script.Something that i notice that on line 87.The

PlayerPrefs.SetInt("xp",int.Parse(w.text));

is not working.I debug.log it.The w.text is working fine but SetInt is not.Please help.Thanks

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)
{
//PlayerPrefs.SetString("name", User);
Debug.Log ("Getting Xp for Stats");
Debug.Log (w.text);
Debug.Log ("Working Stats");
PlayerPrefs.SetInt("xp",int.Parse(w.text));
Debug.Log ("Get xp Worked Stats");
}
else
{
Debug.Log ("Error: " + w.error.ToString());
}
}
}

www.text not returning value in integer format

So ,please check it & instead of using int.Parse use int.TryParse

you need to TryParse, and when it is true let it Parse so like:

bool Result;
int number;

Result = int.TryParse(txt, out number);
if(result){
//parse
}