Hi Maxbenk26,
Okay, try this code. It replicates the code in CMSB:
<?php
header("Content-type: text/plain");
$host = 'localhost:3311'; // default 3306
$user = 'username';
$password = 'password';
$mysqli = new mysqli();
$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 1);
$result = $mysqli->real_connect(
hostname: $host, // can also contain :port
username: $user,
password: $password,
flags : 0,
);
// on connect error
if (!$result) {
die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
// on success
echo 'MySQL successfully connected to: ' . $mysqli->host_info . "\n";
Mysqli should be able to take a hostname:port string as the 'hostname' argument.
Let me know if this works for you.
Dave Edis - Senior Developer
interactivetools.com