nlr_p nlr_p - 1 month ago 4x
MySQL Question

post call is not working in node js

I am trying to perform a post call in node js, i am testing it through post but i am not able to retrive data,
my node code,

exports.login = function( req, res ) {
connection.query('SELECT * FROM profile where email =',function(error,result,rows,fields){
// }


my routes,'/login',cors(), admin.login);

i am getting fail and my error is

{ [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 '' at line 1]

my input through postman



Don't build the query string directly, this leaves you open to injection attacks and also chokes on certain characters, as you are experiencing here. Use a placeholder like so:

var query = "select * from profile where email = ?";

connection.query(query, [], function(error,result,rows,fields) {