Error with custom mysql ports
-
If you use custom ports for the mysql server different than 3306, the plugin will fail creating the sitemap.
The error can be found in the line 1881 of file sitemap-core.php in the following line:
$con = mysqli_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
Usually, if you use custom mysql ports you can add it to the global define DB_HOST like ‘localhost:20001’ and wordpress will work fine. The problem is mysqli_connect will accept the custom port as a parameter after DB_NAME. To fix this issue I replaced this line by:
$db_host = DB_HOST;
$db_port = 3306;
if (strpos($db_host, ‘:’)!==false) {
$arr_host = explode(‘:’,$db_host);
$db_host = $arr_host[0];
$db_port = $arr_host[1];
}
$con = mysqli_connect($db_host,DB_USER,DB_PASSWORD,DB_NAME,$db_port);I hope this info helps someone with the same problem.
- The topic ‘Error with custom mysql ports’ is closed to new replies.