function login(email, password, callback){
    var email = email.trim().toLowerCase();
    var password = password.trim();

    var queryString = "SELECT * FROM users where Email ="+"'"+email+"' AND 
Password = '"+password+"'";

    con.query(queryString, function(err, rows){
        if(err){
            throw err;
        }
        callback(rows);
    });
};

login('[email protected]', 'Password', function(results){
    con.end();
    // Do stuff with results
});

On Tuesday, March 28, 2017 at 5:58:47 AM UTC+5:30, SURAJ KUMAR CHANDRA 
wrote:
>
> How do you guys use node js vars.  Please refer to red marking. I am 
> declaring variable at one place trying to use at another place, simply not 
> working.
>
> function login(email,password){ // Returns the login data row
>   var email = email.trim().toLowerCase();
>   var password = password.trim();
>
>  var   result = [];  //*Declaring here* 
>
>   //var queryString = "SELECT * FROM users where Email ="+"'"+email+"'"+ 
> AND Password = +"'"+password+"'";
>   var queryString = "SELECT * FROM users where Email ="+"'"+email+"' AND 
> Password = '"+password+"'";
>
>   //var execQuery = function execQuery(){
>   con.query(queryString,function(err,rows){
>   if(err) throw err;
>
>  // console.log('Data received from Db:\n');
>  //result = result.push('SUCCESS','0000','Data',rows)
>  //console.log(rows);
> result = rows;  // *Want to use here*
>    //return rows;
>
> });
>
>  con.end(); 
>
> //}
> //console.log('Outside function block: '+execQuery());
> return result; /*/ want to see here*
> }
>
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/c4e339af-c4cb-4e47-8a56-3162bb079789%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to