Special characters problem with database
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.
精彩评论