0

I have a Textarea box which onSubmit sends data to the database. I may have hyperlinks in some inputs and when I load the data, I want the link to show up as a hyperlink instead of regular text.

I figured I would try using strpos to try and find all instances of HTTP but then using trim and maybe even explode would become too messy.

if (strpos($data[$i], 'http:') !== false) { }

I know I can just add <a href="link.html">Link</a> in my text area and when it gets pulled out of the database, it will act as a link. However, there is a problem with this, if I want to edit this data again, it adds slashes next to the link <a href="\link.html\">Link</a>.. The link still works but its just extra characters in the database that I don't need. If I edit about 10 times, its going to add 20 slashes to the database.

Any help or assistance to help me get on the right track will be greatly appreciated.

Bhavik P.
  • 905
  • 3
  • 10
  • 28

1 Answers1

0

At some point between your app and the database, you are escaping the string being sent in. When the data gets pulled out of the database, try using stripslashes() on it.

Julian H. Lam
  • 25,501
  • 13
  • 46
  • 73