diff --git a/dmemcache.inc b/dmemcache.inc
index 480dbb749..b4706fda3 100644
--- a/dmemcache.inc
+++ b/dmemcache.inc
@@ -270,20 +270,21 @@ function dmemcache_get($key, $bin = 'cache', $mc = NULL) {
 
   $full_key = dmemcache_key($key, $bin);
   if ($mc || $mc = dmemcache_object($bin)) {
-    $track_errors = ini_set('track_errors', '1');
-    $php_errormsg = '';
+    error_clear_last();
 
     $result = @$mc->get($full_key);
+
     // This is a multi-part value.
     if (is_object($result) && !empty($result->multi_part_data)) {
       $result = _dmemcache_get_pieces($result->data, $result->cid, $bin, $mc);
     }
 
-    if (!empty($php_errormsg)) {
-      register_shutdown_function('watchdog', 'memcache', 'Exception caught in dmemcache_get: !msg', array('!msg' => $php_errormsg), WATCHDOG_WARNING);
-      $php_errormsg = '';
+    $error = error_get_last();
+
+    if (!empty($error)) {
+      register_shutdown_function('watchdog', 'memcache', 'Exception caught in dmemcache_get: !msg', array('!msg' => $error['message']), WATCHDOG_WARNING);
+      error_clear_last();
     }
-    ini_set('track_errors', $track_errors);
   }
 
   if ($collect_stats) {
@@ -398,16 +399,15 @@ function dmemcache_get_multi($keys, $bin = 'cache', $mc = NULL) {
       }
     }
     elseif ($mc instanceof Memcache) {
-      $track_errors = ini_set('track_errors', '1');
-      $php_errormsg = '';
+      error_clear_last();
 
       $results = @$mc->get($full_keys);
 
-      if (!empty($php_errormsg)) {
-        register_shutdown_function('watchdog', 'memcache', 'Exception caught in dmemcache_get_multi: !msg', array('!msg' => $php_errormsg), WATCHDOG_WARNING);
-        $php_errormsg = '';
+      $errors = error_get_last();
+
+      if (!empty($errors)) {
+        register_shutdown_function('watchdog', 'memcache', 'Exception caught in dmemcache_get_multi: !msg', array('!msg' => $errors['message']), WATCHDOG_WARNING);
       }
-      ini_set('track_errors', $track_errors);
 
       // Order is not guaranteed, map responses to order of requests.
       if (is_array($results)) {
