We are testing webissues (version 0.8.3-1) on a Windows 2000 server running apache 2.0.61, mysql 5.0.45 and php5.2.5. The mysqli extension is used, and mysql is configured to use a non-default port different from 3306.
The recommended setting in config.inc.php to use 'host:port' (example: 'localhost:7306') does not work and returns the following error in the log:
[2008-01-17 17:34:57, 192.168.1.22]
WARNING in D:\InetPub\www_support\include\database-mysqli.inc.php(17):
mysqli_connect(): (HY000/2003): Can't connect to MySQL server on 'localhost' (10061)
I am not a php expert, but looking at the php.net manual pages, it looks like the mysqli_connect syntax requires $port to be explicitely and separately indicated in the string.
I have made the following modifications to the files to make it work:
in file config/config.inc.php,
change:
$config[ 'db_host' ] = 'host:port';
to:
$config[ 'db_host' ] = 'host';
$config[ 'db_port' ] = 'port';
in file include/database.inc.php,
change line 45 from:
if ( !wi_db_connect( $config[ 'db_host' ], $config[ 'db_database' ], $config[ 'db_user' ], $config[ 'db_password' ] ) )
to:
if ( !wi_db_connect( $config[ 'db_host' ], $config[ 'db_database' ], $config[ 'db_user' ], $config[ 'db_password' ], $config[ 'db_port' ] ) )
in file include/database-mysqli.inc.php:
change line 13 from:
function wi_db_connect( $host, $database, $user, $password )
to:
function wi_db_connect( $host, $database, $user, $password, $port )
change line 17 from:
$db_link = mysqli_connect( $host, $user, $password, $database );
to:
$db_link = mysqli_connect( $host, $user, $password, $database, $port );
It works for us, but there may be cleaner ways to do it. Over to the experts ;-)
- Log in to post comments
You're right. I never tested it with a non-default port number. A cleaner way to do it is to split $host into host and port in database-mysqli.inc.php so it works the same way as with other engines. I will make fix this bug and release version 0.8.3-2 tomorrow. Thanks a lot for reporting this issue!
Regards,
Michał