gpt4 book ai didi

php - mysqli::mysqli(): php_network_getaddresses: getaddrinfo 失败:名称或服务未知

转载 作者:可可西里 更新时间:2023-11-01 06:48:02 32 4
gpt4 key购买 nike

<分区>

<?php

function getMysqlConnection($host, $user, $pass, $database) {
global $mysqli;
global $Mysqlerror;
$mysqli = new mysqli('$host', '$user', '$pass', '$database');
if (empty($mysqli->connect_errorno) == false) {
$Mysqlerror = "true";
} else {
$Mysqlerror = "false";
}
}

我创建了一个如上所述的函数,它实现了给定 MySQL 用户凭据的连接,我通过使用实现了这个函数

<?php
require 'myFunc.php';
getMysqlConnection("localhost", "wronguser", "wrongpass", " test");
echo $Mysqlerror;

虽然我使用了错误的密码和用户名,但 Mysqlerror 是错误的。我也用过 or die function 没有任何反应

Warning: mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /opt/lampp/htdocs/mysite/myFunc.php on line 5

Warning: mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name or service not known in /opt/lampp/htdocs/mysite/myFunc.php on line 5

我像往常一样重新启动了 lampp

Starting XAMPP for Linux 1.8.0...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
Warning: World-writable config file '/opt/lampp/etc/my.cnf' is ignored
XAMPP: Starting ProFTPD...
/opt/lampp/share/lampp/alladdons: line 23: /opt/lampp/share/addons/: is a directory
XAMPP for Linux started.

我的代码或服务器有问题吗?如何解决?

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com