1

I try to save html content to the database, with ' or " it auto give a slash which is great so I don't have to do mysql_escape_string. However when I load up the string it shows as

<a href=/"yes/">test</a>

and if I save it again I got this

<a href=//"yes//">test</a>

Does that means when I echo out the string I should strip out the slash?

$html = '<a href="yes">test</a>';
$insertStatement = $pdo->prepare('insert into content (html) values (:html)');
$pdo->bindParam(:html, $html);
$pdo->execute();
Zulakis
  • 7,859
  • 10
  • 42
  • 67
Bill
  • 17,872
  • 19
  • 83
  • 131

1 Answers1

1

use

$pdo->bindValue(':html', $html, PDO::PARAM_STR);

instead of

$pdo->bindParam(:html, $html);
Bailey Parker
  • 15,599
  • 5
  • 53
  • 91
Pramendra Gupta
  • 14,667
  • 4
  • 33
  • 34