sending the information to the database fails :C


ArgumentException: JSON parse error: Invalid value.
UnityEngine.JsonUtility.FromJson (System.String json, System.Type type) (at <090959ea8bda448d921c6cab7fb64dba>:0)
UnityEngine.JsonUtility.FromJson[T] (System.String json) (at <090959ea8bda448d921c6cab7fb64dba>:0)
NetworkManager+d__1.MoveNext () (at Assets/Script/NetworkManager.cs:29)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at :0)


using System.Collections;
using System;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Experimental.Networking;

public class NetworkManager : MonoBehaviour
    public void CreateUser(string userName, string email, string pass, Action<Response> response) 
        StartCoroutine(CO_CreateUser (userName, email, pass, response));

    private IEnumerator CO_CreateUser(string userName, string email, string pass, Action<Response> response)
        WWWForm form = new WWWForm();
        form.AddField("userName", userName);
        form.AddField("email", email);
        form.AddField("password", pass);

        UnityWebRequest www = UnityWebRequest.Post("http://localhost/Game/createUser.php", form);
        www.downloadHandler = new DownloadHandlerBuffer();

        yield return www.SendWebRequest();



public class Response 
    public bool done = false;
    public string message = "";

Well, the error is pretty clear. Whatever your createUser.phpscript returns in www.downloadHandler.text is not valid json. Have you actually tried to debug your issue? Have you tried printing what is returned from your script?

We can’t tell what your PHP script returns since we don’t know what that script does. Maybe it doesn’t run properly and throws an exception and the returned text is just an error message and not the result you’re waiting for.

However serverside scripting is out of scope of UnityAnswers. Apart from that we can’t really answer anything since the important parts (the PHP script and / or the actual returned text) are missing.