For some weird reason, the following code is returning null, while the manual states it should either return true or false. There is also no information in the mysqli object.
Code
// Initialize MySQLi
$this->mysqli = new mysqli();
// Connect to the server
var_dump($this->mysqli);
var_dump($this->mysqli->real_connect($host, $username, $password, $database));
var_dump($this->mysqli);
Output
object(mysqli)#2 (17) { ["affected_rows"]=> NULL ["client_info"]=> NULL ["client_version"]=> int(50141) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> NULL ["error"]=> NULL ["field_count"]=> NULL ["host_info"]=> NULL ["info"]=> NULL ["insert_id"]=> NULL ["server_info"]=> NULL ["server_version"]=> NULL ["sqlstate"]=> NULL ["protocol_version"]=> NULL ["thread_id"]=> NULL ["warning_count"]=> NULL }
NULL
object(mysqli)#2 (17) { ["affected_rows"]=> NULL ["client_info"]=> NULL ["client_version"]=> int(50141) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> NULL ["error"]=> NULL ["field_count"]=> NULL ["host_info"]=> NULL ["info"]=> NULL ["insert_id"]=> NULL ["server_info"]=> NULL ["server_version"]=> NULL ["sqlstate"]=> NULL ["protocol_version"]=> NULL ["thread_id"]=> NULL ["warning_count"]=> NULL }
You are not using it correctly.
You need to create the object using
mysqli_init().Or you put the connection info in the constructor and don’t call
real_connect.