mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known

时光怂恿深爱的人放手 提交于 2020-01-01 09:58:12

问题


im working on a website which mostly uses the database. the problem is that im geting the following error: mysqli_connect(): php_network_getaddresses: getaddrinfo failed: Name or service not known I cant figure out how to fix it. I've penta-checked the connect and it seems to be okay.

function connect($hostname, $username, $password, $database)
{
    $conid = mysqli_connect($hostname, $username, $password, TRUE);


    if($conid == FALSE)
    {
        if(DEBUG == TRUE)
        {
            show_error("MySQL Connection using `$hostname`, `$username`, `$password` was refused");
        }

        return;
    }

    else
    {
        $dbid = mysqli_select_db($database, $conid);

        if($dbid == FALSE)
        {
            if(DEBUG == TRUE)
            {
                show_error("MySQL could not connect to database `$database`");
            }

            return;
        }

        else
        {
            self::$connections[] = $conid;
            self::$connection    = $conid;
        }
    }
}

The code is writen in 2010 and then somehow it worked. Is it possible to fixit?


回答1:


It's the server hosting issue. You'd have to check with the hosting.

You can also read more tips at this link: http://albertech.net/2011/05/fix-php_network_getaddresses-getaddrinfo-failed-name-or-service-not-known/




回答2:


Your PHP server upgraded and your hosting didn't support it.




回答3:


I had a similar issue, My Issue was resolved by checking and resolving DNS resolution (in our case, the use in cagefs had different /etc/hosts than the core system)



来源:https://stackoverflow.com/questions/22946763/mysqli-connect-php-network-getaddresses-getaddrinfo-failed-name-or-service

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!