WWW not working
After a couple of hours trying to figure out how to fix this error (I have already look almost all answers of WWW not working and so), I have decided to post it here. Hope someone can help me ^^'
The problem is: I have a very simple call of WWW that sends info to PHP. But, every URL I test it gives me this error:
WWW Error: UnityEngine.Debug:Log(Object) c__Iterator0:MoveNext() (at Assets/SendInfo.cs:25) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
This is my code:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class SendInfo : MonoBehaviour {
 
     public void SendScore()
     {
         string url = "http://www.web.url/sendinfo.php?score=" + Player.totalPoints;
         WWW www = new WWW(url);
 
         StartCoroutine(WaitForRequest(www));
     }
 
     IEnumerator WaitForRequest(WWW www)
     {
         yield return www;
         
         if (www.error == null)
         {
             Debug.Log("WWW Ok!: " + www.text);
         }
         else
         {
             Debug.Log("WWW Error: " + www.error);
         }
     }
 }    
 
               It just can't connect to any URL. Have tried several things, I though it was the PHP code but it isn't. A simple connection to google.com won't work either.
Am I doing something wrong? If not, any way to try to fix? Thank you!
Answer by luguen · Aug 04, 2017 at 09:45 AM
Hello @Davidin99 !
Rather than test this line:
if (www.error == null)
you should use:
if (string.IsNullOrEmpty(www.error))
Your answer
 
             Follow this Question
Related Questions
Load External JPG as TextAsset 1 Answer
Having Trouble with Post to Server 0 Answers
consume a php webservice in Unity3D C# 2 Answers
Get Internet Year PHP 0 Answers
Loading an 'UI skin pack' 1 Answer