Search Unity

NewWorkManager whith phpmyadmin

Discussion in 'Scripting' started by Nixel2013, Dec 12, 2019.

  1. Nixel2013

    Nixel2013

    Joined:
    May 9, 2019
    Posts:
    64
    El error es el siguiente Error:
    ArgumentException: JSON parse error: Invalid value.
    UnityEngine.JsonUtility.FromJson (System.String json, System.Type type) (at C:/buildslave/unity/build/Modules/JSONSerialize/Public/JsonUtility.bindings.cs:42)
    UnityEngine.JsonUtility.FromJson[T] (System.String json) (at C:/buildslave/unity/build/Modules/JSONSerialize/Public/JsonUtility.bindings.cs:30)
    NetWorkManager+<CD_CrearUsuario>d__1.MoveNext () (at Assets/InicioDeSesion/NetWorkManager.cs:25)
    UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)


    Pero el error me redirige la linea 25.


    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using System;
    5. using UnityEngine.Networking;
    6. using System.IO;
    7.  
    8. public class NetWorkManager : MonoBehaviour
    9. {
    10.     public void CrearUsuario(string userName, string email, string password, Action<Response> response)
    11.     {
    12.         StartCoroutine(CD_CrearUsuario (userName, email, password, response));
    13.     }
    14.  
    15.     private IEnumerator CD_CrearUsuario(string userName, string email, string password, Action<Response> response)
    16.     {
    17.         WWWForm form = new WWWForm();
    18.         form.AddField("Usuario", userName);
    19.         form.AddField("Correo", email);
    20.         form.AddField("Contraseña", password);
    21.  
    22.         WWW w = new WWW("http://localhost/DatosGradoDeLibertad/CrearUsuarios.php", form);
    23.         yield return w;
    24.  
    25.         Response respons = JsonUtility.FromJson<Response>(w.text);
    26.     }
    27. }
    28.  
    29. [Serializable]
    30.     public class Response
    31.     {
    32.         public bool Done = false;
    33.         public string Mensaje = "";
    34.     }
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    7,466
    Well, is w.text valid JSON? Because it is just telling you it is not. If that is the case, the issue is likely in your PHP rather than your Unity code. You haven't posted the contents of w.text, so I'm going to assume the error message is correct.
     
    Nixel2013 likes this.
unityunity