Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Problem with www.text

Discussion in 'Multiplayer' started by ManuelCarrasco, Aug 6, 2018.

  1. ManuelCarrasco

    ManuelCarrasco

    Joined:
    Jun 25, 2018
    Posts:
    4
    Hello everyone, I have the following problem. When I try to receive an answer from PHP it works perfectly, but when it comes to making a comparison with that answer in IF I can not make it work because it tells me that it re-evaluates NULL. If I print it by Debug.Log it shows it perfectly, but if I compare it with some string it does not work. Somebody could help me? I leave the code and the error that appears to me when doing the if.

    Para aclarar , intento hacer un login.


    C#

    Code (CSharp):
    1. public class Login : MonoBehaviour {
    2.  
    3.     public GameObject inputID;
    4.     string user;
    5.  
    6.     void Start () {
    7.        
    8.     }
    9.  
    10.     // Update is called once per frame
    11.     void Update () {
    12.        
    13.     }
    14.  
    15.       IEnumerator doLogin(string user)
    16.     {
    17.        // WWWForm form = new WWWForm();
    18.        //form.AddField("user", user);
    19.         WWW www = new WWW("https://localhost/TEST/login.php?user="+user);
    20.  
    21.         yield return (www);
    22.  
    23.      
    24.  
    25.         if (!string.IsNullOrEmpty(www.error))
    26.             Debug.Log(www.error);
    27.  
    28.  
    29.     }
    30.     public void Loguearse()
    31.     {
    32.         user = inputID.GetComponent<InputField>().text;
    33.         StartCoroutine(doLogin(user));
    34.  
    35.      
    36.     }
    37. }

    PHP

    <?php

    include ('conexion.php');


    $usuario= $_REQUEST['user'];


    $sql = "SELECT * FROM usuarios WHERE usuario LIKE '$usuario'";

    $result = mysqli_query($conn, $sql);

    if (mysqli_num_rows($result) > 0) {
    // output data of each row
    echo "fue encontrado";

    } else {
    echo "no encontrado";
    }
    mysqli_close($conn);

    ?>


    ERROR

    Unable to complete SSL connection
    UnityEngine.Debug:Log(Object)
    <doLogin>c__Iterator0:MoveNext() (at Assets/Scripts/Login.cs:32)
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,722
    Do you have proper TLS setup on your local machine?
    Try using http instead of https.
     
    ManuelCarrasco likes this.
  3. ManuelCarrasco

    ManuelCarrasco

    Joined:
    Jun 25, 2018
    Posts:
    4


    use
    if (www.text.Trim () == "1") {
    print ("found"); }



    trim was the answer finally, thanks for answering.