var mysql = require('./../node_modules/mysql');//1. 加载mysql模块 exports.checkRegistered=function(req,resp){ var myConnect = mysql.createConnection({//2.创建数据的链接对象; host:"localhost", user:"root", password:"1234", port:'3306', database:"juewei" }) myConnect.connect();//3. 打开链接; var registeredUsername=req.body.username; //获取用户输入的值 var registeredPassword=req.body.password; var registeredPassword2=req.body.password2; var registeredArray=new Array();//将获得的用户输入值用变量存起来 registeredArray.push(registeredUsername); registeredArray.push(registeredPassword); registeredArray.push(registeredPassword2); //console.log(registeredArray[0]);能够正确输出 //console.log(registeredArray[1]);能够正确输出 //console.log(registeredArray[2]);能够正确输出 //console.log(registeredArray.length);能够正确输出 var registeredMysql="insert into t_juewei(j_username,j_password)values(?,?)"; myConnect.query(registeredMysql,registeredArray,function(err,data){ console.log(data);//这里输出显示undefined!!!!!!!!!!!为什么!!!!!!!!!!!!! }
console.log(data);这里输出显示undefined!!!!!!!!!!!为什么!!!!!!!!!!!!!
JIUK