diff --git a/include/mysqli.php b/include/mysqli.php
index 13ce86ec5ffa293cf91a23de4bfe2dc8e5fe4044..2079318e1f30901f72288bad449b721ed734b26c 100644
--- a/include/mysqli.php
+++ b/include/mysqli.php
@@ -40,7 +40,13 @@ function db_connect($host, $user, $passwd, $options = array()) {
 
     //Connectr
     $start = microtime(true);
-    if(!@$__db->real_connect($host, $user, $passwd)) # nolint
+    $port = 3306;
+    if (strpos($host, ':') !== false) {
+        $_host = explode(':', $host);
+        $host = $_host[0];
+        $port = (int) $_host[1];
+    }
+    if (!@$__db->real_connect($host, $user, $passwd, null, $port)) # nolint
         return NULL;
 
     //Select the database, if any.