- Home /
Why is get_url adding an extra 'http://'? -- DB request fail
I used the Server Side Highscore code I found on the Wiki and added my own customized IEnumerator:
public string userScoreURL = "http://xxxxx.com/displayUser.php?";
IEnumerator GetUserScore(string username)
{
Debug.Log ("Loading scores");
string get_url = userScoreURL + "user=" + WWW.EscapeURL(username);
Debug.Log (get_url); // Used to see what URL it's trying to pass
WWW hs_get = new WWW(get_url);
yield return hs_get;
if(hs_get.error != null)
{
print("There was an error getting your score: " + hs_get.error);
}
else
{
Debug.Log(username + " : " + hs_get.text);
}
}
This is the way I'm using it (bare with me, I'm not an expert): - I created a public method which contains a Subroutine calling the IEnumerator:
public void GetUserScoreCoRoutine(string username)
{
StartCoroutine(GetUserScore(username));
}
From a different script I'm passing the username I'm trying the score for:
public HSController HSScript;
// Use this for initialization void Start () { HSScript = GetComponent<HSController>(); HSScript.GetUserScoreCoRoutine("Tim"); //Tim needs to be replaced by playerPref later on }
So this fails and the I can see from my debug log that the URL passed looks like this: http://http://xxxxx.com/displayUser.php?user=Tim UnityEngine.Debug:Log(Object) c__Iterator2:MoveNext() (at Assets/Script/HSController.cs:89) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) HSController:GetUserScoreCoRoutine(String) (at Assets/Script/HSController.cs:35) DisplayUserScore:Start() (at Assets/Script/DisplayUserScore.cs:11)
Why does it have 2 x http? Is is the reason it's failing? If I test the URL straight in the browser I get the high score correctly so my PHP scrips and DB are working fine.
Thanks for the help.
Your answer
![](https://koobas.hobune.stream/wayback/20220613093055im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to get specific data from CURL in unity 0 Answers
Can't display image from URL using MySQL 000webhost 2 Answers
How do you package/retrieve Asset Bundle Dependencies 0 Answers