diff --git a/include/mysqli.php b/include/mysqli.php
index 86b5a3b7fe0c6a789dfa515afae6f52ce793a76d..443a1544e9ff0b5d90b12009b2d6bb82dde71e8e 100644
--- a/include/mysqli.php
+++ b/include/mysqli.php
@@ -40,6 +40,9 @@ function db_connect($host, $user, $passwd, $options = array()) {
 
     $port = ini_get("mysqli.default_port");
     $socket = ini_get("mysqli.default_socket");
+    $persistent = stripos($host, 'p:') === 0;
+    if ($persistent)
+        $host = substr($host, 2);
     if (strpos($host, ':') !== false) {
         list($host, $portspec) = explode(':', $host);
         // PHP may not honor the port number if connecting to 'localhost'
@@ -54,6 +57,9 @@ function db_connect($host, $user, $passwd, $options = array()) {
         }
     }
 
+    if ($persistent)
+        $host = 'p:' . $host;
+
     // Connect
     $start = microtime(true);
     if (!@$__db->real_connect($host, $user, $passwd, null, $port, $socket))
diff --git a/setup/inc/class.installer.php b/setup/inc/class.installer.php
index b43c083da79e297e22a8462b526fc9e3192040f0..d08fc34ed0f5a4b9890baf07fb0b6012e965a059 100644
--- a/setup/inc/class.installer.php
+++ b/setup/inc/class.installer.php
@@ -60,6 +60,7 @@ class Installer extends SetupWizard {
         $f['dbuser']        = array('type'=>'string',   'required'=>1, 'error'=>'Username required');
         $f['dbpass']        = array('type'=>'string',   'required'=>1, 'error'=>'password required');
 
+        $vars = array_map('trim', $vars);
 
         if(!Validator::process($f,$vars,$this->errors) && !$this->errors['err'])
             $this->errors['err']='Missing or invalid data - correct the errors and try again.';