For inserting strings into database, I apply this function on the string:
$string = strip_tags($string);
$string = htmlspecialchars($string);
$string = preg_replace('/\s+/', ' ', $string); // removing multiple spaces :-)
$string = preg_replace('/(?:\s\s+|\n|\t)/', ' ', $string);
$string = mysql_real_escape_string($string);
On my localhost while I test the app, I enter: Life's Interesting
and the exact string saves into db (Life's Interesting), then I uploaded my app on the real server, when I enter the same string, it saves: Life\'s Interesting
in database!
Why is this happening on just the server and not on my local host? I'm using Wamp on my localhost. what configuration I need to change on the server so it saves right in db?
Thanks in advance