Php 如何在Ajax中保存ckeditor值?
使用Angular AJAX在数据库中保存CKEDITOR值时遇到问题。我不知道这是一个角度的问题还是仅仅是PHP。顺便说一下,我在应用程序中使用了CodeIgniter 3 以下是我的一些代码,我希望您理解我的代码: 我的编辑: 我在这里保存一份协议 以下是AJAX保存:Php 如何在Ajax中保存ckeditor值?,php,ajax,angularjs,codeigniter,Php,Ajax,Angularjs,Codeigniter,使用Angular AJAX在数据库中保存CKEDITOR值时遇到问题。我不知道这是一个角度的问题还是仅仅是PHP。顺便说一下,我在应用程序中使用了CodeIgniter 3 以下是我的一些代码,我希望您理解我的代码: 我的编辑: 我在这里保存一份协议 以下是AJAX保存: $scope.saveContent = function() { $scope.totals = [{ 'subtotals' : computeGrandTotal(), 'v
$scope.saveContent = function() {
$scope.totals = [{
'subtotals' : computeGrandTotal(),
'vat_rate' : quoteList.vat_rate,
'grandtotal': computePercentage()
}];
$http({
url: "<?php echo base_url('index.php/tutorial/submitQuotation'); ?>",
method: 'POST',
data: $.param({
quotation: $scope.quoteHeader.items,
msc: quoteList, //here goes the agreeement content
totals: $scope.totals
}),
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}).success(function(data){
alert('Data successfully inserted!');
}).error(function(){
alert('Error Occured!');
});
}
当我检查我的开发人员控制台时,我得到了一个错误,因为来自我的CKEDITOR的值是以HTML而不是代码呈现的
我尝试使用stripslashes()和$this->db->escape(),但仍然出错
你能帮我吗?好的,我解决了我的错误。以下是我在查询中所做的:
$sqlInsertQuotationAgreement = "INSERT INTO quotation_agreement SET quotation_id = " . (int)$quotationID . ", agreement = \"" . htmlspecialchars($agreement) . "\"";
好的,我试着使用这个函数,它得到了我的html数据:
htmlspecialchars()
但是我得到了这个错误:你的SQL语法有错误;检查与MySQL服务器版本相对应的手册,了解使用near的材料和碎石以及机器和设备的正确语法,第1行通常应为c
$sqlInsertQuotationAgreement = "INSERT INTO quotation_agreement SET quotation_id = " . (int)$quotationID . ", agreement = \"" . htmlspecialchars($agreement) . "\"";