[英]Import node.js variable into database
我编写了这段代码,并尝试运行它以便使用node.js变量更新数据库。 脚本可以工作,但是输入字符串“ $ var”而不是实际结果。 请帮忙。
谢谢。
var TOTP = require('onceler').TOTP;
setInterval(function() {
// create a TOTP object with your Secret
var totp = new TOTP('CODEHERE');
$var:{totp.now}
// print out a code that's valid right now
console.log(totp.now());
$q="UPDATE auth SET auth =$var where id='1'";
con.query(
$q,function(err,rows){
if (err) throw err;
console.log('Data received');
console.log(rows);
})},5000);
尝试:
$q="UPDATE auth SET auth = '" + $var + "' where id='1'";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.