title: Get data from php into c# script
body: <p>I have a unity3d c# script for get data from php file.</p>
  
  <p><strong>Unity C# file:</strong></p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  public class FrmPhp : MonoBehaviour {
  
      // Use this for initialization
      void Start () {
          string url = "http://localhost/abc/PgComm.php";
          WWW www = new WWW(url);
          StartCoroutine(WaitForRequest(www));
      }
      IEnumerator WaitForRequest(WWW www)
      {
          yield return www;
          // check for errors
          if (www.error == null)
          {
              Debug.Log("Text : "www.text);
              Debug.Log("DownLoad Bytes: "www.bytesDownloaded.ToString());
          } else {
              Debug.Log("WWW Error: "+ www.error);
          }       
      }
  
      // Update is called once per frame
      void Update () {
  
      }
  }
  </code></pre>
  
  <p><strong>PHP file</strong></p>
  
  <pre><code>&lt;html&gt; 
      &lt;body&gt; 
          &lt;table name="mytable" border="0" cellspacing="0" cellpadding="0"&gt; 
              &lt;tr&gt; 
                  &lt;td&gt; 
                      Friend ID 
                  &lt;/td&gt; 
  
              &lt;/tr&gt; 
          &lt;?php 
          $db = pg_connect('host=localhost dbname=MyDB user=postgres password=xyz'); 
  
          $query = "SELECT pk FROM Table1"; 
  
          $result = pg_query($query); 
          //printf ("&lt;tr&gt;&lt;td&gt;%s&lt;/td&gt;", $result); 
  
          if (!$result) { 
              echo "Problem with query " . $query . "&lt;br/&gt;"; 
              echo pg_last_error(); 
              exit(); 
          } 
  
          while($myrow = pg_fetch_assoc($result)) { 
              printf ("&lt;tr&gt;&lt;td&gt;%s&lt;/td&gt;", $myrow['pk']); 
  
          } 
          ?&gt; 
          &lt;/table&gt; 
      &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p>What I am getting in unity is </p>
  
  <pre><code>Text :
  DownLoad Bytes: 110
  </code></pre>
  
  <p>Any Idea how to get data from php .</p>
  
  <p><strong>Edit c# Code :</strong></p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine.Experimental.Networking;
  
  public class FrmPhp : MonoBehaviour {
      public Text txt;
      string url = "http://192.100.233.222/abc/Hello.php";
      byte[] results;
      //byte results1 = 0x00;
      // Use this for initialization
      void Start () {
          StartCoroutine(GetText());
      }
  
      IEnumerator GetText() 
      {
          UnityWebRequest www = UnityWebRequest.Get(url);
          yield return www.Send();
  
          if(www.isError) {
              Debug.Log(www.error);
              txt.text = www.error;
          }
          else {
              // Show results as text
              //results1 = 0x01;
              Debug.Log(www.downloadHandler.text);
              txt.text = www.downloadHandler.text;
          }
      }
      // Update is called once per frame
      void Update () {
  
      }
  }
  </code></pre>