Hi, I'm currently using Ckeditor for posting blogs to a site, and also for editing original posts.
However, when I try and edit the post and update the content via AJAX, using getData(), any apostrophes I put in come back as "'", is this meant to happen? I don't know how I can convert them in PHP, does it have a special function for this?
I've tried html_entity_decode and htmlspecialchars_decode but having no luck.
Can anyone tell me where I'm going wrong?
Calls this function:
Which goes to:
Any help is greatly appreciated,
Thanks.
Edit: Any alerts I've put in there are just for debugging purposes, so I can see what's going where.
However, when I try and edit the post and update the content via AJAX, using getData(), any apostrophes I put in come back as "'", is this meant to happen? I don't know how I can convert them in PHP, does it have a special function for this?
I've tried html_entity_decode and htmlspecialchars_decode but having no luck.
Can anyone tell me where I'm going wrong?
<input type="button" value="Update" onclick="updateTextarea(CKEDITOR.instances.editortextarea.getData(), <?php echo $post[0]; ?>);"/>
Calls this function:
function updateTextarea(text, id) { if(text != '') { alert(text); $('#textareaupdate').html('Updating...'); $('#textareaupdate').show(); $.ajax({ type: "POST", url: "edit.php", data: 'textarea=' + text + '&id=' + id + '&mode=text', success: function(msg) { if(msg == 'fail') $('#textareaupdate').html('Failed to update content :('); else { $('#textareaupdate').html('Done!'); } alert(msg); setTimeout(function () { $('#textareaupdate').hide(); }, 2000); } }); } }
Which goes to:
else if(isset($_POST['textarea']) && $_POST['textarea'] != '' && isset($_POST['id']) && is_numeric($_POST['id']) && isset($_POST['mode']) && $_POST['mode'] == 'text') { if($text = str_replace('src="../ckfinder', 'src="ckfinder', $_POST['textarea'])) { $text = html_entity_decode($text); } else { $text = html_entity_decode($_POST['textarea']); } $text = mysql_real_escape_string($text); $id = mysql_real_escape_string($_POST['id']); if(!$update = mysql_query("UPDATE `blog` SET `content` = '{$text}' WHERE `id` = {$id} ")) echo 'fail'; }
Any help is greatly appreciated,
Thanks.
Edit: Any alerts I've put in there are just for debugging purposes, so I can see what's going where.