Skip to content
Advertisement

EXPRESS and SQL “syntax error at or near “$””

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.

Advertisement

Answer

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

UPDATE users SET user_profile_image = $1 WHERE user_id = $2
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement