开发者

Special characters problem with database

开发者 https://www.devze.com 2023-03-06 12:25 出处:网络
I am trying to add special characters into database with JavaScriptusing encodeURIComponent but it works in localhost and in server adding \' an extra / is also added infront of \' .

I am trying to add special characters into database with JavaScript using encodeURIComponent but it works in localhost and in server adding ' an extra / is also added infront of ' .

开发者_开发技巧

How to prevent this?


This is what I have so far:

var qn_text = encodeURIComponent($('#question_text').val()); 

question_text is the field ID.

$.ajax({ type: "POST", url: "<?= site_url('admin/inputdata')?>", 
                       data: "qn_text ="+qn_text, 
                       success: function(msg) { } 
      });

admin is my controller and then to model. If I enter special character like +'&, all these characters are entered in local database correctly. But at server side the characters like ' entered but an extra / is appended infront of ' .


You need to disable magic_quotes on your server. See disabling magic quotes in the PHP manual.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号