gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-11-01 00:35:28 25 4
gpt4 key购买 nike

您好,我正在使用 Node js 处理 mysql 数据库。插入了大部分数据,但此时查询卡住了,我不知道为什么。我尝试了 mysql.escape()utf8.encode() 但仍然是同样的错误。

这是我的查询

                ms_connect.query("INSERT INTO `companies_jobs` VALUES (null, '"+mysql.escape(data[i].title)+"','"+mysql.escape(data[i].link)+"','"+mysql.escape(data[i].date)+"','"+mysql.escape(data[i].level)+"','"+mysql.escape(data[i].category)+"','"+mysql.escape(data[i].function)+"','"+mysql.escape(data[i].loc)+"','"+mysql.escape(data[i].timing)+"','"+mysql.escape(data[i].company)+"','"+JSON.stringify(time)+"','"+JSON.stringify(date)+"',"+1+")", function(err, row){
if(err){
console.log(data[i]);
throw err;
} else{
i++;
s();
}
})

我正在尝试将此数据插入数据库:

[{
category: 'Sales',
company: '',
date: 'Posted on 12/06/2018',
function: '',
level: 'Students',
link: 'https://career5.successfactors.eu/career?career%5fns=job%5flisting&company=LiMySLive&navBarLevel=JOB%5fSEARCH&rcm%5fsite%5flocale=en%5fUS&career_job_req_id=13305&selected_lang=es_ES&jobAlertController_jobAlertId=&jobAlertController_jobAlertName=&_s.crb=fl08QG2oV1akJFW%2fWVQ4Ol50v%2bs%3d',
loc: 'Chile (CL)',
timing: 'full time',
title: 'Alumno en Practica'
}]

但是由于某些原因,我得到了这个错误:

ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Alumno en Practica'',''https://career5.successfactors.eu/career?career%5fns=job%' at line 1

表结构是这样的:

enter image description here

最佳答案

看起来 mysql.escape(data[i].title) 已经在您的值周围放置了单引号,因此您通过自己添加它们来将其加倍。

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com