0

I want to insert this inside my table in Postgres but I don't know how to escape the special characters. Also, my string is much longer than the one below but contains many such instances.

'<a href='http:\/\/%%code%%' target='_blank'>'
2
  • i think you need to change your datatype of your filed, now you need to add text as datatype instead of your right now datatype, so you can store html directly on database filed.. Commented Apr 28, 2016 at 4:11
  • 3
    Are you using prepared statements? If so you don't need to do anything special. If not, use prepared statements. Commented Apr 28, 2016 at 4:11

1 Answer 1

2

Please use pg_query_params in any data going into a Postgresql database or a similar method that escapes the string correctly. Do not under any circumstances trust any encoding coming from a client ie a Browser.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.