This continues to be posed a couple of occasions in a variety of places, however i haven't found a definative and obvious answer. Most solutions involve people telling disable Miracle Quotes around the php.ini file (that we did) or modifying core Wordpress files.

Anyways, now you ask , this: why do each time I personally use $wpdb->insert or $wpdb->update a slash will get added before any single quote. So for example:

I have eaten bananas becomes I've eaten bananas

Here is a sample code I made use of:

$id = $_POST['id'];
$title = $_POST['title'];
$message = $_POST['message'];

$wpdb->update('table_name', array('id'=>$id, 'title'=>$title, 'message'=>$message), array('id'=>$id))

Exactly the same problem was here: Wordpress Database Output - Remove SQL Injection Escapes however it never was solved apart from "disable miracle quotes"

After investing your day about this, the reply is the following:

Wordpress escapes in the $_Publish declaration, not in the actual place, that is bizarre.

$id = stripslashes_deep($_POST['id']); //added stripslashes_deep which removes WP escaping.
$title = stripslashes_deep($_POST['title']);
$message = stripslashes_deep($_POST['message']);

$wpdb->update('table_name', array('id'=>$id, 'title'=>$title, 'message'=>$message), array('id'=>$id));

Doing this means that Wordpress won't add slashes before any quotes.

a bit more info--WordPress made the decision to create people think these were going insane with the addition of 'magic quotes' even when you've first got it switched off beginning in version 3.. Any use of $_REQUEST, $_GET, $_Publish, $_COOKIE, or $_SERVER is going to be affected. See wp-includes/load.php.

 /* Add magic quotes to $_GET, $_POST, $_COOKIE, and $_SERVER.
 * @since 3.0.0
 */
function wp_magic_quotes() {
        // If already slashed, strip.
        if ( get_magic_quotes_gpc() ) {
                $_GET    = stripslashes_deep( $_GET    );
                $_POST   = stripslashes_deep( $_POST   );
                $_COOKIE = stripslashes_deep( $_COOKIE );
        }

        // Escape with wpdb.
        $_GET    = add_magic_quotes( $_GET    );
        $_POST   = add_magic_quotes( $_POST   );
        $_COOKIE = add_magic_quotes( $_COOKIE );
        $_SERVER = add_magic_quotes( $_SERVER );

        // Force REQUEST to be GET + POST.
        $_REQUEST = array_merge( $_GET, $_POST );
}