Here's what I do
I passed a variable like this to the gateway:
$lastname = "O\'Donnell";
When I logged into the gateway interface I see that it shows: O'Donnell.
which is what I want.
Now, I create a form that posts O'Donnell to this variable:
$lastname = $_POST['lastname'];
That causes my db to not accept the insert. So I try addslashes:
$lastname = addslashes($_POST['lastname']);
And this inserts just fine to my database. But in the gateway interface I see: O\'Donnell
Then I try
$lastname = mysql_real_escape_string($_POST['lastname']);
I get the same results.
Am I missing anything? I am passing the lastname via curl, if this helps.