Hi I am working on mysql database with node js. Much of the data get inserted but at this point the query stuck, I don't know why. I tried mysql.escape() and utf8.encode() but still the same error.
This is my query
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();
}
})
I am trying to insert this data into the database :
[{
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'
}]
But due to some reason, I get this error :
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
This is how the table structure :

JSON.stringify(time)andJSON.stringify(date)in your query, but the key time is not included in the data you want to insert into the database. Did you perhaps meanJSON.stringify(data[i].timing)andJSON.stringify(data[i].date)?mysql.escape(data[i].function)