0

I am using html,php to feed into my sql database. I want to know if there is any way to take data from HTML input tag, convert it to its HTML equivalent (eg © to &copy ) and then input into the sql database query. Can it be done with SQL or will require PDO or SQLi? If thats not possible , please suggest some alternative

  • 1
    Why do you need to do so? Is your database using 7-bit US-ASCII? – Álvaro González Apr 05 '16 at 11:50
  • The issue is when i feed data from html form , only first letter is stored in database. Is it because I am not using PDO ? –  Apr 05 '16 at 11:55
  • Probably not. I'm sure that people who use other database extensions do not need to store texts one letter at a time. Please let me close this question as duplicate and check the linked question. If it still doesn't answer your question please let me know and I'll reopen it. – Álvaro González Apr 05 '16 at 11:59
  • I dont think so that both are same, thats regarding setting character set and mine is regarding converting the input. I will search for answer over there :) –  Apr 05 '16 at 12:04
  • 1
    Linked question explains everything about hammers and you are asking what kind of shoe is better to drive a nail. Whatever, I see you've already accepted an answer so it's alright. – Álvaro González Apr 05 '16 at 12:20
  • :) yes that answer worked –  Apr 05 '16 at 12:55

1 Answers1

0

Have a look at htmlspecialchars and htmlentities if you have the possibility to convert your strings in PHP before inserting:

htmspecialchars Documentation

htmlentities Documentation

tobspr
  • 8,200
  • 5
  • 33
  • 46