mysql - ER_PARSE_ERROR : You have an error in your SQL syntax;

标签 mysql node.js

为什么不起作用? 我想下载txt并保存在数据库中。

Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual th at corresponds to your MySQL server version for the right syntax to use near 'a/ innego komunikatora. Z góry, wielkie dzięki. Temat będzie aktualizowany w m' at line 1

代码

var cheerio = require('cheerio');
const request = require('request');
var mysql = require('mysql');


var con = mysql.createConnection({
  password..
});


con.connect(function(err) {
  if (err) throw err;
  console.log("Connected!");
});


let x=1;

function downlad(){
    x++;
    request.get(`http://wklejto.pl/638151`, (err, response, body) => {
        console.log(response.statusCode);
        const $=cheerio.load(
          body,
          { decodeEntities: false });

        const el = $('.de1').html();

        con.query("INSERT INTO `wklejki` (`ID`, `txt`) VALUES (NULL, '"+el+"');");

        console.log(el);
    });
}downlad();

Enter image description here

最佳答案

替换

con.query("INSERT INTO `wklejki` (`ID`, `txt`) VALUES (NULL, '"+el+"');");

con.query('INSERT INTO wklejki SET ?', {ID: null, txt: el}, function (error, results, fields) {
    //Whatever you want to do next.
});

关于mysql - ER_PARSE_ERROR : You have an error in your SQL syntax;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56543121/

相关文章:

php - 写入 mysql 数据库的值不正确

php - 将数组从 url 传递到 mySQL 查询

node.js - 在服务器内存中生成 zip 文件并作为下载 Node.JS 发送到客户端

node.js - 在mongodb中创建空集合

mysql - vb.net System.ArgumentOutOfRangeException 未处理

php - 使用 php、ajax 和 jquery 对 mysql 表进行排序

node.js - fs.rename ENOENT : no such file or directory

javascript - socket.io 和 Nodejs Controller 的问题

javascript - 样式和 javascript 文件不适用于在 Node.js 中提供 HTML 的页面

MySQL DATE_FORMAT 没有以正确的顺序输出日期