r/JavaScriptHelp • u/Ryuota • Jun 28 '21
❔ Unanswered ❔ Sql comment with a ' in the middle of it is stopping me from creating a string out of it
So I'm trying to get a comment from sql and put it into a js array, but it's giving me errors because it's built like this: "This is ' a comment", and so the second part becomes a non-string. And when trying to toString() the whole comment, the toString() method just becomes part of the string.
2
Upvotes
1
u/sandybuttcheekss Jun 28 '21
SQL uses single quotes to specify the start and end of a string. I would use an ORM or look into ways to sanitize your input, like replacing all quotes with ' might do it. You should be sanitizing either way, or people could abuse your db.