阅读背景:

从mysql数据库中获取记录时节点js出错

来源:互联网 

Routes:

exports.authenticate = function(req, res) {

    //connection.connect();
    var sql="SELECT * from users where username='"+req.body.user+"' and password='"+req.body.pass+"' LIMIT 1";
    connection.query(sql, function(err, rows, fields) {
        if (err) throw err;

        //res.send('Your data is: ', rows);
        var str="Hi, <b>"+rows[0].name+"</b> ("+rows[0].email+")";

        sql="SELECT username,name from users ORDER BY name";
        connection.query(sql, function(err, datarows, fields) {
            if (err) throw err;
            //res.send('Your data is: ', rows+' <br/> All Users are : ', datarows.length+"<a href='/go.html?url=/'>Login</a>");
            console.log(datarows);
            res.render('home.jade', {title: 'Home',result:datarows});
           /*---------------The above calling jade-----------------*/   
        });

        //str+="<a href='/go.html?url=/'>Login</a>";
        //res.send(str);
        //connection.end();
    });
exports.authenticate = function(req, 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: