Reputation:
I have this string:
x = "<?xml version="1.0" encoding="UTF-8"?>"
But when I insert it gives problems with the quotes. How can I change the quotes to take the entire string?
I get the string from a query, I don't create it
Upvotes: 1
Views: 451
Reputation: 656
Escape your doublequote for mysql.
x = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
Look at this answer. It may be helpful. Click here
You can also escape double quote using regex. Look
Hope this helps you
Upvotes: 3
Reputation: 4059
You always want to use a parameterized query when creating SQL commands. How you do that varies based upon which database server you are using and what language and components you use to connect to it.
Injection attacks are the number 1 (according to the OWASP Top 10) vulnerability in web sites today.
Upvotes: 0
Reputation: 77
If you're using ES6, you can use template literals.
I also recommend using more descriptive variable names:
const xmlVersion = `<?xml version="1.0" encoding="UTF-8"?>`
Upvotes: 0
Reputation: 106
x = "<?xml version='1.0' encoding='UTF-8'?>"
or
x = ""
x = "<?xml version='1.0' encoding='UTF-8'?>"
//or
x = `<?xml version='1.0' encoding='UTF-8'?>`
Upvotes: 0