Sunday 21 May 2017

javascript mysql inside function

When I run this function I get null when it comes back because I have the return inside the mysql query how can i solve this?

function CheckStorage(Host, Slots, SSLocation) {
    connection.query("SELECT * FROM `machines` WHERE `shost` LIKE '" + Host + "' AND `location` LIKE '" + SSLocation + "' AND `slotsa` >= " + Slots + "", function(err, rows, fields) {
        if(rows[0]) {
            console.log(rows[0]["ip"]);
            return rows[0]["ip"];
        } else {
            return false;
        }   
    });
}



via Raul Gonzales

No comments:

Post a Comment