I'm looking for a way to handle HTML content within prepared statements.
My application provides a basic WYSIWYG Editor and after the user is saving the content my script stores HTML-Data in an sqlite database.
But if i'am using a prepared statement my HTML gets -naturally- escaped.
This is what i've so far:
try {
/* Create databases and open connections */
$dbh = new PDO( 'sqlite:db/coaching.sqlite' );
/* Set Error Mode for Exception Handling */
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
/* Prepare SQL Statement */
$query = $dbh->prepare( "UPDATE Content SET Value=:value WHERE Token=:token" );
/* Bind Param to Statement */
$query->bindParam( ':token', $_POST['id'], PDO::PARAM_STR);
$query->bindParam( ':value', $_POST['value'], PDO::PARAM_STR);
/* Execute Query */
$query->execute();
/* Echo Data */
echo $_POST['value'];
/* Close connections to Database */
$dbh = NULL;
}
catch( PDOException $e ) {
/* Print Error-Messages */
echo $e->getMessage();
}