使用mysqli

时间:2015-11-23 20:56:33

标签: php jquery mysql mysqli contenteditable

我正在尝试将contentEditable div中的数据保存到mySql DB。但似乎“+”符号无法存储在DB中。这是正确的概念还是我错过了什么?

的index.php

<div id="la_sent" contentEditable=true></div>
<button class="saveChanges">Save changes</button>

的script.js

$(document).ready(function(){
  $( ".saveChanges" ).click(function() {
      content = $('#la_sent').html();
      dataUrl = "iid=1&content="+content;
      $.ajax({
        url:"ajax.php",
        type:"POST",
        data:dataUrl,
        success:function(data){
            ...
      }});
  }); 
}); 

ajax.php

$type = $_POST['iid'];
$content = $_POST['content'];
$mysqli=connect_database(); //connection to database
$stmt = $mysqli->prepare('UPDATE email_structure SET content = ? WHERE type = ?');
$stmt->bind_param('ss', $content, $type);
$ress = $stmt->execute();
$stmt->close();
$mysqli->close();
echo "OK";

例如:如果我在div元素字符串'a + b + c'中写入,则在DB字符串'a b c'中添加。知道为什么吗?

0 个答案:

没有答案