diff --git a/include/mysqli.php b/include/mysqli.php
index ad545a5dbfd8a9fae8206c0e6e14189809e1105b..e60a97e97a56e8dfb0c828eede2bd9f8ba759c35 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.