Unity with mysql

1

I have problems with Unity and mysql , trying to bring the only table I have in a database on the Square7 server, and what shows when calling what the table has is what they see in the image. : (

This is the php code

<?php
m_internal_encoding("UTF-8");
$enlace=mysqli_connect("localhost","cristian","xxxxxxxx","cristian_players");
if(mysqli_connect_errno()){
    printf("Conexion Fallida: %s\n",mysqli_connect_error());
    exit();
}

mysqli_set_charset($enlace,"utf-8");
$consulta = "SELECT * FROM 'Puntajes' ORDER by 'puntuacion' DESC LIMIT 10";
$resultado=mysqli_query($enlace,$consulta);

$num = mysqli_num_rows($resultado);

for($i=0;$i<$num;$i++){
    $row=mysqli_fetch_array($resultado,MYSQLI_ASSOC);
    echo  $row['Nombre']. ";" . $row['puntuacion']. ";";

}

?>

And this is the UNITY code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class verJugadores : MonoBehaviour {

    private string URLVerPuntuacion = "cristian.square7.ch/RankingScripts/VerPuntuacion.php";
    private List<Jugador> RankingJugadores = new List<Jugador>();
    private string[] CurrentArray = null;
    public Transform tfPanelCargarDatos;
    public Text txtCargandoDatos;
    public GameObject PanelPre;

    void Start() {
        StartCoroutine(ObtenerJugadores());
    }

    IEnumerator ObtenerJugadores() {
        txtCargandoDatos.text = "Cargando...";
        WWW DataServer = new WWW("http://"+URLVerPuntuacion);
        yield return DataServer;
        if (DataServer.error != null)
        {
            Debug.Log("Problemas al intentar obtener los jugadores de la base de datos: " + DataServer.error);
            txtCargandoDatos.text = DataServer.error;
        }
        else {

            txtCargandoDatos.text = "";
            ObtenerRegistros(DataServer);
            VerRegistros();

        }
    }

    void ObtenerRegistros(WWW DataServer) {
        CurrentArray = System.Text.Encoding.UTF8.GetString(DataServer.bytes).Split(";"[0]);
        for (int i = 0; i <= CurrentArray.Length - 3; i = i + 2) {
            RankingJugadores.Add(new Jugador(CurrentArray[i],CurrentArray[i+1]));
        }
    }

    void VerRegistros() {
        for (int i = 0; i < RankingJugadores.Count; i++) {
            GameObject obj = Instantiate(PanelPre);
            Jugador jg = RankingJugadores[i];
            obj.GetComponent<setScore>().SetScore(jg.Nombre, jg.puntuacion);
            obj.transform.SetParent(tfPanelCargarDatos);
            obj.GetComponent<RectTransform>().localScale = new Vector3(1, 1, 1);
        }
    }

}

public class Jugador
{
    public string puntuacion;
    public string Nombre;

    public Jugador(string nombreJugador, string puntuacionJugador) {
        puntuacion = puntuacionJugador;
        Nombre = nombreJugador;
    }
}
    
asked by Cristian Ramírez 20.01.2018 в 03:25
source

0 answers