我有以下脚本:
radioStation.on('metadata', function(metadata) {
var values = (metadata.StreamTitle).split('-').map(i=>i.trim());
var artist = values[0];
var title = values[1];
console.log('webstream');
console.log(artist);
console.log(title);
var con = mysql.createConnection({
host: "localhost",
user: "root",
password: "",
database: "radio"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
var sql = "INSERT INTO webstream (artist, title) VALUES ( " + artist + " ," + title + ")";
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
con.query(sql, function (err, result) {
if (err) throw err;
console.log("1 record inserted");
});
});
});
当我执行脚本时,我会得到一个er\u parse\u错误。
有人知道我做错了什么吗?
1条答案
按热度按时间mrwjdhj31#
@史蒂夫在正确的轨道上。也许这会有帮助: