Reputation: 19308
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();
Upvotes: 1
Views: 4051
Reputation: 14873
use
$pdo->bindValue(':html', $html, PDO::PARAM_STR);
instead of
$pdo->bindParam(:html, $html);
Upvotes: 1