Reputation: 1045
I'm following php/mysql tutorial book. The sample script connects me to my mysql database doesn't show what it should.
The line in question is
("Host information: %\n", mysqli_get_host_info($mysqli));
There rest of the code
<?php
$mysqli=new mysqli("localhost", "root", "Im not pasting this", "or this");
if (mysqli_connect_errno()){
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
} else {
printf("Host information: %\n", mysqli_get_host_info());
}
?>
I just i get "Hostname: " on the screen.
Upvotes: 1
Views: 208
Reputation: 7739
You need to specify your mysqli object in mysqli_get_host_info()
function - http://php.net/manual/en/mysqli.get-host-info.php. Try this code:
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
/* print host information */
printf("Host info: %s\n", $mysqli->host_info);
/* close connection */
$mysqli->close();
?>
Upvotes: 2