我在使用角AJAX在数据库中保存CKEDITOR值时遇到了问题。我不知道是角度问题还是PHP问题。顺便说一下,我在我的应用程序中使用了CodeIgniter 3。
下面是我的一些代码--我希望你能理解我所拥有的:
我的CKEDITOR:我在这里保留一份协议
以下是AJAX的保存:
$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!');
});
}在我的模型中,我这样做:
$sqlInsertQuotationAgreement = "INSERT INTO quotation_agreement SET quoatation_id = " . (int)$quotationID . ", agreement = '" . $agreement . "'";
$queryInsertQuotationAgreement = $this->db->query($sqlInsertQuotationAgreement);当我检查我的开发人员控制台时,我得到了一个错误,因为我的CKEDITOR的值是用HTML而不是在代码中呈现的。
我尝试使用strip斜杠()和$this->db->转义(),但仍然出错。
你能帮我做这个吗?
发布于 2015-07-13 02:35:17
好的,我解决了我的错误。以下是我在查询中所做的工作:
$sqlInsertQuotationAgreement = "INSERT INTO quotation_agreement SET quotation_id = " . (int)$quotationID . ", agreement = \"" . htmlspecialchars($agreement) . "\"";https://stackoverflow.com/questions/31374422
复制相似问题