I have a link: http://www.adress.com/Article.aspx?ID=262839&R=R1
After using mysql_real_escape_string on it, it changes to http://www.adress.com/Article.aspx?ID=262839
So it removes everything from the &-char: "&R=R1".
Why? And how can I fix this?
--- EDIT Thanks for the answers. I will look in to the PDO.
And of course you were right, the problem is not caused by mysql_real_escape_string. The data is lost in my jquery ajax request.
$('.share').live('click', function(event) {
var thesharelink = $(this);
var thehref = $(this).attr('href');
$(this).hide();
$.ajax({
url: 'edit.php',
type: 'POST',
data: 'thehref=' + thehref,
error: function(){
$(thesharelink).replaceWith("Could not share");
},
contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
success: function(result1) {
$('body').append(result1);
$(thesharelink).replaceWith(msg);
}
});
});
So once the data arrives to the php-file, it is lost. It seems like adding escape fixes the problem. Although I welcome any suggestions for improvement.