Hi the code below loads a single field from a mysql database, but when it gets to the point result[0].IdUtente the error below is generated. How do I solve it?
ERROR:
throw err; // Rethrow non-MySQL errors
^
TypeError: Cannot read property 'IdUtente' of undefined
CODE:
var query = "SELECT IdUtente FROM Utente WHERE Username = " + sql.escape(Username) + " and Password=MD5(" + sql.escape(Password) + ") and Tipo!='Risorsa' ";
var ret=DbConfig.query(query, function (err, result) {
if (err) {
console.log("Errore login: " + err);
}
else {
console.log(result[0].IdUtente);
IdUtente = result[0].IdUtente;
}
});