Home > Net >  EXPRESS and SQL "syntax error at or near "$""
EXPRESS and SQL "syntax error at or near "$""

Time:02-21

I'm making PFP route with EXPRESS and PSQL and I have a little problem.

I get an error

Syntax error at or near "$"

Code:

if (!imgbbLink.startsWith("https://ibb.co/")) {
  return res.status(400).json("Something went wrong")
}

await pool.query(
  "UPDATE users SET user_profile_image = 1$ WHERE user_id = $2",
  [imgbbLink, req.user.id]
)

res.json("PFP updated successfully")

I think there shouldn't be any problem?

Thanks.

CodePudding user response:

You just made typo when indicated 1$ instead of $1:

UPDATE users SET user_profile_image = $1 WHERE user_id = $2
  • Related