Hi all,
I'm having that oldschool issue with saving rich text content to MySQL and then retreiving it. As far as I'm concerned I thought I was doing it correctly - but one of you lucky devils is about to tell me otherwise :D
When I'm saving to DB:
if(isset($_SESSION['auth'], $_POST["topicid"], $_POST["response"])){
$configureEntities = htmlentities($_POST['response']);
$formattedResponse = mysqli_real_escape_string($configureEntities);
$mysqliDebug = true;
$mysqli = mysqli_connect($config['host'], $config['user'], $config['pass'], $config['db']);
$date_added=date('Y-m-d H:i:s');
$query = "INSERT INTO topic_response(topicid,usersid,response,date_added) VALUES (?, ?, ?, ?)";
$stmt = $mysqli->prepare($query);
$stmt->bind_param('ssss', $_POST['topicid'], $userInfo['id'], $formattedResponse, $date_added);
$result = $stmt->execute();
}
When I'm echoing response data:
`echo stripslashes($topicResponseInfo['response']);`
I also have the entity encoding feature to TinyMCE set to raw:
`entity_encoding : "raw"`
However... if I use the formatting features in TinyMCEsuch as bold, underline, font types, font sizes and so forth the submission is stored in MySQL as null
. I did have it working at one point, but only for certain features, as I was able to submit <p>I love this!</p>\n<p>It\'s quite good you see.
and it was successfully saved to SQL. There were however other things breaking it such as font size. Totally baffled.
//This:
<p>I love this!</p>\n<p>It\'s quite good you see.
//Came from submitting this:
I love this!
It's quite good you see.
The real question is, with rich text editors, how do you correctly encode, escape and recall?
Thanks in advance, repuation to the beautiful person who clearly explains the correct way of storing and then echoing RTE generated strings!
Michael