最も可能性の高い問題は、あるサーバでmagic_quotesを有効にして、他のサーバでは有効にしないことです。 無効magic_quotesのいずれか、またはコードに変更します。
$example = stripslashes($_POST['example']); //undoes the magic_quotes
$escaped_string = mysql_real_escape_string($example); //escapes it properly.
あなたが開いていること、接続に応じて、異なる動作しますmysql_real_escape_string
2つの異なるデータベース・サーバ
から2つの接続を持っている場合は可能性が低いシナリオが発生する可能性があります。
複数のサーバーがあり、複数の接続がある場合は、接続ごとに1回エスケープ機能を実行する必要があります。
例
$example = "a'b";
$connectionA = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$connectionB = mysql_connect('remotehost', 'mysql_user', 'mysql_password');
$escapedstringA = mysql_real_escape_string($example, $connectionA);
$escapedstringB = mysql_real_escape_string($example, $connectionB);
あなたはmysql_real_escape_string
への呼び出しで接続パラメータを省略した場合、両方のescapedstringsが間違っていた、remotehostのデフォルトのエンコーディングを使用してエスケープされます。
このコードが間違って動作することがあります。
$example = "a'b";
$connectionA = mysql_connect('localhost', 'mysql_user', 'mysql_password');
$connectionB = mysql_connect('remotehost', 'mysql_user', 'mysql_password');
$escapedstringA = mysql_real_escape_string($example); //uses remotehost's encoding
$escapedstringB = mysql_real_escape_string($example);
しかし、magic_quotesはサーバではオフになっていて、もう一方ではオフになっていますか? –