Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未使用PHP显示Mysql主机信息_Php_Mysql_Database Connection - Fatal编程技术网

未使用PHP显示Mysql主机信息

未使用PHP显示Mysql主机信息,php,mysql,database-connection,Php,Mysql,Database Connection,我正在学习php/mysql教程。示例脚本将我连接到mysql数据库,但没有显示它应该做什么 有问题的路线是 ("Host information: %\n", mysqli_get_host_info($mysqli)); 还有其他的代码 <?php $mysqli=new mysqli("localhost", "root", "Im not pasting this", "or this"); if (mysqli_connect_errno()){ printf("C

我正在学习php/mysql教程。示例脚本将我连接到mysql数据库,但没有显示它应该做什么

有问题的路线是

("Host information: %\n", mysqli_get_host_info($mysqli));
还有其他的代码

 <?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());
}
?>


我只是在屏幕上看到了“Hostname:”。

您需要在
mysqli\u get\u host\u info()
函数中指定您的mysqli对象。请尝试以下代码:

     <?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();
?>