Hey all i seem to be having problems with getting the full HTML code from the tinyMCE box when sending over to my PHP page to save to the database.
My Ajax code is this:
console.log('type=' + theType + '&rID=' + theReplyID + '&email=' + $('#email').val() + '&name=' + $('#name').val() + '&fb=' + FB + '&com=' + tinyMCE.activeEditor.getContent());
$.ajax({
type: "post",
url: "post.php",
cache: false,
data: 'type=' + theType + '&rID=' + theReplyID + '&email=' + $('#email').val() + '&name=' + $('#name').val() + '&fb=' + FB + '&com=' + tinyMCE.activeEditor.getContent(),
success: function(data,status){
showMsgBox('Your comment has been posted!','OK','blue');
},
error: function(xhr, desc, err){
showMsgBox('Error while saving comment data','OK','red');
}
});
The console.log outputs the correct test data:
type=C&rID=&[email protected]&name=david dev&fb=na&com=<p>this is just a test </p>
<p>here </p>
<p>and here</p>
But when it saves it to my database it only has:
<p>this is just a test
My PHP page looks like this:
<?PHP
$type = $_POST['type']; //R(reply) or C(comment)
$email = $_POST['email'];
$name = $_POST['name'];
$fb = $_POST['fb'];
$comment = $_POST['com'];
$dbhandle = mysql_connect("xx.xxx.xxx.xxx", "xxxxx", "xxxxx") or die(mysql_error());
mysql_select_db("Gvth") or die(mysql_error());
$result = mysql_query("SELECT * FROM UserInfo WHERE Email = '" . $email . "'");
$count = 0;
while($row = mysql_fetch_assoc($result)) {
$count++;
$id = $row["id"];
}
mysql_close($dbhandle);
$dbhandle = mysql_connect("xx.xxx.xxx.xxx", "xxxxx", "xxxxx") or die(mysql_error());
mysql_select_db("Gvth") or die(mysql_error());
$result = mysql_query("INSERT INTO UserComments (UserInfoID,Comment,ImageUploaded,commentID,accepted,dt)
VALUES (" . $id . ",'" . $comment . "','na'," . $id . random_numbers(4) . ",1,'" . date('Y-m-d g:i:s',time()) . "');");
mysql_close($dbhandle);