Mysql int/data to a variable/int Javascript

Ok so i have this script “connector.js”

    if(login) {
        GUI.BeginGroup(new Rect(10,10,200,400),"");
        GUI.Box(Rect(0,0,190,140),"Account");
        GUI.Box(Rect(0,30,190,20),"username");
        nom = GUI.TextField (Rect (0, 50, 190, 20), nom, 20);
        GUI.Box(Rect(0,70,190,20),"Password");
        pass = GUI.TextField (Rect (0, 90, 190, 20), pass, 20);
        if(GUI.Button(Rect(0,130,190,20),"Login")) {
            connection.Open(); //on ouvre la connexion
            //commandsql = MySqlCommand("SELECT level,gold,health,exp,damage FROM users WHERE name = "+nom+" and pass = "+pass+";",connection);
            commandsql = MySqlCommand("SELECT level FROM users WHERE name = 'dick' and pass = 'fag';",connection);
            lecteurbdd = commandsql.ExecuteReader(); //on envoie la requete
            connection.Close();
            login = false;
        }
    }

most importantly this line here

          commandsql = MySqlCommand("SELECT level FROM users WHERE name = 'dick' and pass = 'fag';",connection);

when i run this in my phpmyadmin ,i get a value of 58 for the level

how do i make it so i can get the value from “level” in mysql to a var level : int = 0; kinda thing.

bump any help?

bump

I don’t use js in Unity, but based on how I would do it in C#, here’s what I would insert into your code:

...
lecteurbdd = commandsql.ExecuteReader();
while (lecteurbdd.Read()) { // only execute if there are rows returned
    level = lecteurbdd.GetInt32(0); // 0 in this case means the first column in your sql
}
...

The “GetInt32()” command is dependant on the data type stored in the MySQL database. Could be Int32, Int16, Int64, Decimal, etc… Here is a list of all the GetXXX() methods on the datareader class: http://dev.mysql.com/doc/connector-net/en/connector-net-ref-mysqlclient-mysqlcommandmembers.html#connector-net-ref-mysqlclient-mysqldatareadermembers